我有Spring网络套接字的稳定性问题。有时我会遇到与https://jira.spring.io/browse/SPR-12812中描述的类似的例外情况。
补丁不可用,然后我用自定义SubProtocolWebSocketHandler实现了我自己的代码。
public class WBSSubProtocolWebSocketHandler extends SubProtocolWebSocketHandler { private static final Logger LOG = LoggerFactory.getLogger(WBSSubProtocolWebSocketHandler.class); public WBSSubProtocolWebSocketHandler(MessageChannel clientInboundChannel, SubscribableChannel clientOutboundChannel) { super(clientInboundChannel, clientOutboundChannel); } @Override public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception { super.afterConnectionClosed(session, status); LOG.debug("WebSocket Connection closed for client with session ID {}", session.getId()); } @Override public void afterConnectionEstablished(WebSocketSession session) throws Exception { // WebSocketHandlerDecorator could close the session // https://jira.spring.io/browse/SPR-12812 if (!session.isOpen()) { LOG.warn("WebSocket Connection established for client with session ID {} was closed.", session.getId()); return; } super.afterConnectionEstablished(session); LOG.debug("WebSocket Connection established for client with session ID {}", session.getId()); } @Override public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception { super.handleTransportError(session, exception); LOG.warn("WebSocket transport error for client with session ID {}", session.getId()); } @Override public void handleMessage(WebSocketSession session, WebSocketMessage message) throws Exception { super.handleMessage(session, message); LOG.debug("Websocket incoming message ({}) from client with session ID {}", message.getPayload().toString(), session.getId()); } @Override public void handleMessage(Message message) throws MessagingException { super.handleMessage(message); LOG.debug("Websocket incoming message : {}, header {}", message); } }
现在我的问题是重现异常以查看问题是否已解决。我试过各种方法,但没有成功。我无法重现连接的关闭。有没有人有想法?
我们还有第二个问题。客户端应用程序(angularjs应用程序)有时会报告socket-web连接丢失。但我不明白为什么因为在服务器上我没有日志中的错误/警告。 如何识别问题并重现?