Reputation: 225
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.
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
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