3

Not sure why I am getting this issue, But My Websocket Connection works on specific ISP while fails on others. I know it sounds absurd but it is happening. My websocket connection works on Two ISP while fails on one. I am using Wildfly Application Server serving the WS Connection and Apache WebServer for proxy forwarding.

Here is the detail of my Request/Response,

General

Request URL:ws://example.com/chat/3
Request Method:GET
Status Code:101 Switching Protocols

Response Headers

Connection:Upgrade
Content-Length:0
Date:Fri, 13 May 2016 13:09:11 GMT
Origin:http://example.com
Sec-WebSocket-Accept:pPjTLv5Dz+/vyjY/SkeMihaXDd0=
Sec-WebSocket-Location:ws://example.com/chat/3
Server:WildFly/9
Upgrade:WebSocket
X-Powered-By:Undertow/1

Request Headers

Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:Upgrade
Cookie:mp_c4f10660603c33a8e9307b70e6767539_mixpanel=%7B%22distinct_id%22%3A%20%2215210855b11180-0ffdda567-1821170c-d37aa-15210855b123f2%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D; mf_user=a60cd2cdcfc41836645d949f71ee3127; intercom-id=d1af89ac-9d55-4fef-8a17-3848d8ef0fce; wooTracker=VQf16pMBx4Pu; _ga=GA1.2.544774749.1447732319; JSESSIONID=z4a1hBpQJQz4YCsLivHRRFf8b0dzYzBsT_4PLadB.ip-172-30-0-20; mf_154095de-56ef-4099-9976-f9a298cf0677=8438220eda64d856436d798ca0b9188a|05132367e34aabbf7bcce5b1e8811235b0bd15d4|1463144963483||19|
Host:example.com
Origin:http://example.com
Pragma:no-cache
Sec-WebSocket-Extensions:permessage-deflate; client_max_window_bits
Sec-WebSocket-Key:94OH1SxHvszgJO6Rg31WGA==
Sec-WebSocket-Version:13
Upgrade:websocket
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36

However, When I tried testing some of the Demo Sites like http://websocket.org/echo.html they are working as expected.

The only difference I found between those connections was header on response from the server Upgrade:websocket whereas my server is returning Upgrade:WebSocket as part of the response. However, I believe that the header are case insensitive and it shouldn't be the issue.

Also, Is it possible to rewrite the Header value for the Response using apache header mod?

Runcorn
  • 5,144
  • 5
  • 34
  • 52
  • if the header is cas sensitive then that might be your problem as youmentioned yourself. Just to make sure did you open the right ports so that the connection can be made. Apache allows custom headers using mod_headers. – mitchken May 18 '16 at 09:38
  • The connection is fine. The Websocket connection is established and is automatically closed with error code 1006 without any message. – Runcorn May 18 '16 at 09:40
  • If your browser client reports close code 1006, then you should be looking at the websocket.onerror(evt) event for details. If you could provide the code where you open the connection that would be great – mitchken May 18 '16 at 09:45
  • Note that browsers will often report a close code 1006 if there is an error during the HTTP Upgrade to Websocket (this is the step before a websocket is technically "connected"). For reasons such as bad authentication or authorization, or bad protocol use (such as requesting a subprotocol, but the server itself doesn't support that same subprotocol), or even an attempt at talking to a server location that isn't a websocket (such as attempting to connect to ws://images.google.com/(which does not exist)) – mitchken May 18 '16 at 09:46
  • 1
    If the network communications involves an IIS-based reverse proxy, then the Sec-WebSocket-Extensions:permessage-deflate will cause problems. http://stackoverflow.com/questions/38933815/iis-8-websockets-with-permessage-deflate http://stackoverflow.com/questions/33272786/websockets-on-tomcat-8-iis-8-with-arr-3-are-not-working http://stackoverflow.com/questions/34316825/websockets-reverse-proxy-in-iis-8/37757417#37757417 – buzz3791 Oct 20 '16 at 15:38
  • I am not using IIS. But, Still thanks for the hint. I will go through the link you have provided and try to figure out the issue. – Runcorn Oct 20 '16 at 16:00

0 Answers0