jaspervdj/websockets — Issue #14: Strange Disconnect Issue with HTTPS
Author: a-wild-tigger
Created: 2012-01-31 09:21:43+00:00
State: open

First off, I think this is a pretty awesome package! Thanks for all your great work on it!

I'm trying to setup a basic web sockets connection with SSL. I found your other project https://github.com/jaspervdj/websockets-snap, and tried to modify it to support this pattern. For the most part it works, but fails on disconnects, when the user closes the browser.

The Server code is here: https://github.com/jaspervdj/websockets-snap
The Client Javascript code is here: https://gist.github.com/1709573
To generate a certificate: https://gist.github.com/1709595

The client code is no different from your example except for an additional line with "wss".

I spent quite some time trying to fix it myself, but unsuccessfully. It doesn't seem to be an issue with the browser, as I verified with the command "tcpdump -i lo0 port 9160", and chrome is sending disconnects when the browser is closed, both for regular http and https (secure websockets).

I also did some digging into the Snap source but it is successfully getting the disconnects and shutting down the sockets appropriately (tested lines 40-41 of https://github.com/snapframework/snap-server/blob/master/src/Snap/Internal/Http/Server/ListenHelpers.hs).

I'm still struggling to understand what escapeHttp does and how it works. When it says "escapes all http traffic", does that mean it drops any incoming http packets?

This might be an issue with snap-server, but given the fact it is correctly closing https and http traffic correctly, I thought it might be more appropriate to list the issue here.

Please let me know if I can help in any way, or there is any clarification required.