2

I have a site using websockets secure (WSS) and works very well in chrome.

Testing in IE and Edge also works however in the browser console I get Network Error 12152 which will also trigger the websocket.addEventListener("error",function(){}) if implemented.

Everything actually works I just get this error which doesnt seem to break anything.

Error is triggered When socket is closed from Browser Side

Headers in EDGE enter image description here

More Info: Example of the code I use

//connect via wss then
ws.addEventListener("error",function(event){ // this hits when Socket is closed})
ws.addEventListener("open",function(){
       ws.addEventListener("message",function(event){
        //do stuff
        ws.Close()
       })
})

To Confirm the problem further

I went to https://www.websocket.org/echo.html in edge the site which has the ability to test websocket connections. I made it connect to my server. which opens the connection without a problem. However in just the same way I have been getting problems with my code. This site also throws an error when I click the disconnect button. See Image Below. Is this a bug in IE/Edge? enter image description here

My Server isnt disconnecting correctly? I use the above site with the default destination (Their websocket server) and not mine. There are no errors. But when connecting to mine on disconnect there are errors.

What could be the problem?

Thanks

SammyG
  • 299
  • 1
  • 4
  • 15

2 Answers2

2

Looking at the Microsoft KB article you are not givng back the expected response/headers on connection setup

From the microsoft knowledge base

12152 ERROR_HTTP_INVALID_SERVER_RESPONSE

The server response could not be parsed.

From the developper docs of mozilla if you look at the Server Handshake Response part

When it gets this request, the server should send a pretty odd-looking (but still HTTP) response that looks like this (remember each header ends with \r\n and put an extra \r\n after the last one):

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=

So, I suggest you check your headers and see which responses you are sending on the handshake, so you keep in line with protocols.

Community
  • 1
  • 1
Tschallacka
  • 27,901
  • 14
  • 88
  • 133
  • Headers look fine for me. And my websocket Server in C# would terminate the connection if not correct. Ill add screen shots of the headers to the question – SammyG Oct 12 '15 at 11:54
  • Yea, the headers look fine, what does the exception message state and tracelog? At which point does it exactly trigger? on handshake, after handshake? on receiving handshake? On pushing first data? What is the code you use to set up the connection? – Tschallacka Oct 12 '15 at 12:01
  • Looking at the timing at which the error is triggered. it is when the connection is Closed from the browser side. How would I bring up a tracelog? I will also put in example code of how I do my operations. – SammyG Oct 12 '15 at 12:18
  • Just found i get the same error from another site. see question. – SammyG Oct 12 '15 at 12:50
  • It might need an reason code for edge/ie http://stackoverflow.com/questions/18803971/websocket-onerror-how-to-read-error-description how to get the error. Try to analyse the event object by doing `console.log(event);` and viewing the properties and output in console. Do you happen to use this libary? https://github.com/websockets/ws/tree/master/examples – Tschallacka Oct 12 '15 at 14:56
0

I have fixed the same error in IE browsers. Check the capitalization of the first letter of websocket.

  • Non IE browser:

    Upgrade: **w**ebsocket

  • IE browser:

    Upgrade: **W**ebsocket

OneHoopyFrood
  • 3,829
  • 3
  • 24
  • 39