pladaria / reconnecting-websocket

Reconnecting WebSocket. For Web, React Native, cli (Node.js)
MIT License
1.22k stars 197 forks source link

receive a imcomplete message #22

Closed eruca closed 7 years ago

eruca commented 7 years ago

I use golang implement the websocke server and reconnecting-websocket in browser;the server log print the server send the complete message to the browser, but the browser only recevie imcomplete message.


const ws = new ReconnectingWebSocket("ws://" + url, undefined, {debug: true});

    ws.onmessage = e => {
        if (typeof e.data === "string") {
            emitter(JSON.parse(e.data));
        } else {
            console.debug("[WebSocket] get data is not string, but", typeof e.data, "e:", e)
        }
    };

browser throw error of JSON.parse(), and the receive data is below:

{"type":"FETCH_ASSESSMENTS_SUCCESSED","payload":{"n
pladaria commented 7 years ago

I guess this is a problem with your server. Try to reproduce using the browser's WebSocket. reconnecting-websocket is just a thin layer over the native WebSocket.

Please, re-open this issue if you reproduce the problem using my library and not using the native WebSocket.