• I had problems getting WS to work with the latest nodejs ws version (1.1.0) as a server.

    The trick for me was to add a "return" statement in the first if block of the "parseData" method (roughly line 117 of wsx.js) to prevent the other statements to execute and produce unexpected results in some cases. After I did this change the connection was not directly terminated any longer.

    My ultimate goal is to get it running together with cloudflare (as they now support websocket connections in free plans).
    I did some changes that significantly improved the behaviour:

    Added the hostname to the handshake (otherwise reverseproxies can not handle the request)
    Removed the Origin from the handshake (otherwise correct WS servers would decline the connection because of CORS problems, however it is optional for devices like espruino)
    Added XOR encryption for the send method as this is mandatory for clients to do

    Further I also try handle binary data, however this is experimental and has nothing to do with cloudflare.

    Now cloudflare finally accepts the connection and even forwards my first message, however the connection is terminated right after that. When not using cloudflare (and connecting directly) everything works as it should. Does anyone have a clue what could be the problem?


    1 Attachment

About

Avatar for urbiman @urbiman started