hagsteel / swampdragon

swampdragon
Other
557 stars 74 forks source link

the ws connection is interrupted #177

Open siwiak opened 8 years ago

siwiak commented 8 years ago

Hi,

When I try to run the code, I get following error:

The connection to ws://localhost:9999/data/370/y4i961mr/websocket was interrupted while the page was loading.

I it some generic bug (I found related thing in socket.io http://stackoverflow.com/questions/14140414/websocket-interrupted-while-page-is-loading-on-firefox-for-socket-io) or I could make some error, if so, what shall I present here?

Thanks

nsomaru commented 8 years ago

I faced this issue when some of my django code was misbehaving, ymmv. Also, you might want to properly set up swampdragon logging to console so you can see what's going on (add this to your loggers key in LOGGING:

        'tornado.general': {
            'handlers': ['console'],
            'level': 'DEBUG',
            'propagate': True,
        },
AlexejStukov commented 8 years ago

Hi @siwiak, you could try my fork. It does not fix the websocket connection error, but it should fix the js-client, so it reconnects after the error.

mengjiin commented 8 years ago

I encountered the same issue with swampdragon 0.4.2.2 too with FireFox. So I downloaded AlexejStukov's fork and did 'diff' between his fork and the release code. I didn't see any significant differences though. Then I noticed that swampdragon/swampdragon/static/swampdragon/js/src/connection.js has a commit on Feb 23, 2015 which contains the following code:

function connect () { connection.socket = new SockJS(getHost()); connection.socket.onopen = onopen; connection.socket.onclose = onclose; connection.socket.onmessage = onmessage;

window.onbeforeunload = function () {
    connection.socket.close();
};

}

Here the socket is closed before unload. What I don't understand is why the onbeforeunload portion is removed in the next commit on Mar 1, 2015. I manually copied the onbeforeunload portion to my connection.js and didn't see the issue with FireFox anymore, in other words, it seems to resolve the issue. My question: is it safe for me to add this onbeforeunload portion back to connection.js? There must be a reason why it was removed in the next commit.

Thanks!

AlexejStukov commented 8 years ago

@mengjiin My fork just fixes a typo in swampdragon.js. Without this fix swampdragon does not automatically reconnect on connection loss.