6 Replies Latest reply on Sep 23, 2015 3:14 PM by paic RSS
    guyhu Newbie

    Is the WsEms websocket handshake case-sensitive?

    Hi,

     

    I am using a reverse proxy which supports the websocket protocol (IIS 8.5 with ARR 3.0). The WsEms is unable to complete the handshake in this setup.

    When the WsEms points directly to the Thingworx server the handshake succeeds.

     

    The only difference I seem to notice are the HTTP headers Upgrade & Connection for which Apache & IIS provide different case-sensitive values.

     

    I am using:

    Thingworx 6.0.3 on Apache Tomcat/8.0.24 with JVM 1.8.0_51-b16.

    WsEms 5.2.2.32.

     

    Example handshake with Apache:

    GET /Thingworx/WS HTTP/1.1
    User-Agent: ThingWorx C SDK
    Upgrade: websocket
    Connection: Upgrade
    Host: <xxx>
    Sec-WebSocket-Version: 13
    Sec-WebSocket-Key: bT+qM+nEa0IIw5trnRHJ1Q==
    Max-Frame-Size: 8192
    appKey: 1fb1bb36-53f5-4b1f-8ae0-9f995986ed7d

     

    HTTP/1.1 101 Switching Protocols
    Server: Apache-Coyote/1.1
    Upgrade: websocket
    Connection: upgrade
    Sec-WebSocket-Accept: a3FB2f1VwcQ6AKKMzavtKvgmw8I=
    Date: Mon, 17 Aug 2015 15:05:39 GMT

     

    Example handshake with IIS:

    GET /Thingworx/WS HTTP/1.1
    User-Agent: ThingWorx C SDK
    Upgrade: websocket
    Connection: Upgrade
    Host: <xxx>
    Sec-WebSocket-Version: 13
    Sec-WebSocket-Key: Wu55ekCBNCnLU5+FJD480g==
    Max-Frame-Size: 8192
    appKey: 1fb1bb36-53f5-4b1f-8ae0-9f995986ed7d

     

    HTTP/1.1 101 Switching Protocols
    Upgrade: Websocket
    Server: Microsoft-IIS/8.5
    Sec-WebSocket-Accept: +hoNr0m+DA+Haj70/LMowOGJ9TM=
    X-Powered-By: ARR/3.0
    Connection: Upgrade
    X-Powered-By: ASP.NET
    Date: Tue, 18 Aug 2015 09:57:11 GMT

     

    When receiving the IIS response the WsEms reports:

    [ERROR] 2015-08-18 11:56:12,541 SDK: ws_on_header_value: Invalid 'upgrade' header: Websocket

    [ERROR] 2015-08-18 11:56:12,541 SDK: ws_on_header_value: Invalid 'connection' header: Upgrade

     

     

    BTW, according to RFC 6455 - The WebSocket Protocol both Apache & IIS seem to use wrong case-sensitivity:

    5.  If the server chooses to accept the incoming connection, it MUST

           reply with a valid HTTP response indicating the following.

    ...

           2.  An |Upgrade| header field with value "websocket" as per RFC2616 [RFC2616].

           3.  A |Connection| header field with value "Upgrade".

     

     

    Is it possible to update the WsEms so it does a case-insensitive comparison for these header values?