cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Is the WsEms websocket handshake case-sensitive?

guyhu
1-Visitor

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?

6 REPLIES 6
Aanjan
12-Amethyst
(To:guyhu)

Quick question - this is specific to IIS/ ASP.NET, correct? Do you have or have you tried with any other proxy server like nginx?

guyhu
1-Visitor
(To:Aanjan)

I did try another reverse proxy, Apache's httpd with proxy_wstunnel_module enabled. This works fine since Tomcat is based on httpd and therefor uses the same case-sensitivity for the http header values.

The issue is not really the proxy being used, but the fact that the WsEms seems to be compatible only with the responses as coming from a httpd (or derivative) web server. I believe removing the case-sensitivity in the WsEms would fix this.

Aanjan
12-Amethyst
(To:guyhu)

That looks to be it. I tried using nginx (which uses lowercase headers), and that connects fine too. I'll talk to the devs and get back to you. Thanks!

Aanjan
12-Amethyst
(To:guyhu)

Hey,

Just wanted to give you a quick update on this issue - it has been fixed! The release timeline for the new WSEMS is approximately at 2 weeks, so I can let you know if you want once the new version is out.

Thanks again!

guyhu
1-Visitor
(To:Aanjan)

Hello,

Is this new version available already?

Thanks

paic
12-Amethyst
(To:guyhu)

A new version was just released.

Announcements


Top Tags