2

I am getting error 1006 on my Web-socket API. I have two machines, and code works fine in one and in the second one I get 1006 error when I send a message from my back-end server.

Here is my code:

var ws = new WebSocket("ws://localhost:8080/handler");

ws.onopen = function()
{
  ws.send("Message send");
  alert("Connection success...");
};

ws.onmessage = function (evt) 
{ 
  var received_msg = JSON.parse(evt.data);
};

ws.onerror = function(e){};

ws.onclose = function(er)
{ 
  alert("Connection is closed..."); 
};
KAD
  • 10,972
  • 4
  • 31
  • 73
jithin
  • 61
  • 1
  • 1
  • 6
  • Close Code 1006 is a special code that means the connection was closed abnormally (locally) by the browser implementation. – Maheshwar Ligade Jun 28 '17 at 06:02
  • @MaheshwarLigade so can you tell me what could be the cause as this code completely works in my other machine with the same backend api – jithin Jun 28 '17 at 07:04
  • 1
    https://stackoverflow.com/questions/19304157/getting-the-reason-why-websockets-closed-with-close-code-1006 – Maheshwar Ligade Jun 28 '17 at 07:06

0 Answers0