• Ok, I fixed it myself. The reason why the code was disconnecting all the time when using cloudflare was the following: The handshake was transmitted in two chunks (each chunk has a wrapped around it here):

    <DATA>HTTP/1.1 101 Switching Protocols
    Date: Sun, 08 May 2016 08:59:10 GMT
    Connection: upgrade
    Set-Cookie: __cfduid=xxx; expires=Mon, 08-May-17 08:59:10 GMT; path=/; domain=.urbiworx.de; HttpOnly
    Upgrade: websocket
    Sec-WebSocket-</DATA>
    <DATA>Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=
    Server: cloudflare-nginx
    CF-RAY: 29fbb6cda43e26d2-FRA
    </DATA>
    

    So what happend here was, that during the handshake one data packet was received with an "H" at the beginning (first chunk) that did not contain the "Accept" Header (that is in the second chunk) and so was interpreted as WS message. "H" in hexadecimal is "48" which is the worst that could happen as it means opcode "8" - terminate connection.

    I now changed the code accordingly so that chunks do not get interpreted as message as long as the handshake is not finished.
    It is not yet implemented optimal right now however it works much better than before.


    1 Attachment

About

Avatar for urbiman @urbiman started