没有连接到spring websocket服务器

时间:2017-12-01 10:51:40

标签: react-native spring-websocket

它没有连接到websocket服务器。我正在使用webstomp-client for native native.Plz,帮帮我吧! 这是我的代码,

Opening Web Socket...
webstomp.js:243 Web Socket Opened...
webstomp.js:243 >>> CONNECT
accept-version:1.2,1.1,1.0
heart-beat:10000,10000

和记录......

{{1}}

提前致谢。

1 个答案:

答案 0 :(得分:0)

Got the same issue. Had to implement a custom WebSocketHandlerDecorator with:

public void handleMessage(final WebSocketSession session, final WebSocketMessage<?> message) throws Exception {
    if (message instanceof TextMessage) {
        TextMessage msg = (TextMessage) message;
        String payload = msg.getPayload();
        // only add \00 if not present (iOS / Android)
        if (!payload.substring(payload.length() - 1).equals("\u0000")) {
            super.handleMessage(session, new TextMessage(payload + "\u0000"));
            return;
        }
    }

    super.handleMessage(session, message);
}

Based on https://github.com/facebook/react-native/issues/12731