Anton_Sh
Anton_Sh

Reputation: 225

WebSocket closes under Internet Explorer - error code 1006

My WebSocket implementation works correctly in Chrome and Firefox.

In IE11 I get this error:

Websocket Error: Network Error 12152, The server returned an invalid or unrecognized response

I use js WebSocket class and reactPhp and https://github.com/ratchetphp/RFC6455 for backend.

This is the request-response data under IE. It looks ok to me. enter image description here

I checked that Websocket returns code 1006 and empty reason.

How can I fix the IE11 error?


The problem was that in response headers I should return only one protocol in Sec-WebSocket-Protocols.

Why it doesn't work only under IE - because I split the protocols in backend by comma+space but IE return the protocols without space only with comma separator. The other browsers return the protocols with comma+space.

For example the code right in backend it looks like that:

array_map('trim', explode(',', $this->headers['Sec-WebSocket-Protocol']));

Upvotes: 0

Views: 1065

Answers (1)

Anton_Sh
Anton_Sh

Reputation: 225

The problem was that in response headers I should return only one protocol in Sec-WebSocket-Protocols.

Why it doesn't work only under IE - because I split the protocols in backend by comma+space but IE return the protocols without space only with comma separator. The other browsers return the protocols with comma+space.

For example the code right in backend it looks like that:

array_map('trim', explode(',', $this->headers['Sec-WebSocket-Protocol']));

Upvotes: 1

Related Questions