I'm working on an app that uses a LabVIEW implemented server on the backend that is proxied via apache. It works great on desktops and android devices but on iPhone and iPad the websocket connection always fails and provides code 1006 in the close event. (No reason)

The request as received in LabVIEW:

GET /r9000_ws HTTP/1.1
Host: localhost:54663
Pragma: no-cache
Cache-Control: no-cache
Sec-WebSocket-Key: ucoJ2G1XNSntZAOBCfG+uQ==
Sec-WebSocket-Version: 13
Sec-WebSocket-Extensions: x-webkit-deflate-frame
User-Agent: Mozilla/5.0 (iPad; CPU OS 9_3_5 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13G36 Safari/601.1
X-Forwarded-Server: localhost
Upgrade: WebSocket
Connection: Upgrade

And the response I'm sending back:

HTTP/1.1 101 Switching Protocols
Upgrade: WebSocket
Connection: Upgrade
Sec-WebSocket-Accept: NUDL0C4/691VkogIvxQRHM1xJA8=

I have tried this in both google chrome and safari on an older iPad. Unfortunately due to the fun of WebSocket security I can't get any useful information on where the failure resides. Thanks to anyone that can see what I'm missing!

  • \$\begingroup\$ How are you creating the websocket? (I'm not familiar with LabVIEW so this may be a silly question) \$\endgroup\$
    – Mattia
    Commented Feb 20, 2018 at 18:08
  • \$\begingroup\$ Also, I just noticed I posted this on GameDev. Whoops. \$\endgroup\$ Commented Feb 20, 2018 at 23:25

1 Answer 1


In my case the problem was the line endings being generated in part of the response header I was creating in LabVIEW. I had a pre-built string that included everything but the base64 handshake, and then manually added the line endings to the end. The first 3 lines only ended with \r instead of the necessary \r\n. I discovered the discrepancy when checking the http traffic with Wireshark.

Everything except iOS was happy to accept the malformed line endings.

  • \$\begingroup\$ You might want to mark this answer as the accepted one :) \$\endgroup\$
    – Vaillancourt
    Commented Sep 20, 2018 at 2:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .