jeudi 24 décembre 2015

Javascript WebSocket in client gives "Invalid frame header" in chrome

So I have a client that's opening a simple web socket in javascript. Here's the code:

var ws = new WebSocket("ws://waihoilaf.duckdns.org:53000");

  ws.onopen = function(){
    console.log("Opening up a socket.");
  }

  ws.onmessage = function(evt){
    console.log("Received message: " + JSON.parse(evt.data));
  }

  ws.onclose = function(){
    console.log("Closed the socket.");
  }

  function thing(){
    console.log("Sending a message...");
    var message = {"message":"Some message", "some number":3};
    ws.send(JSON.stringify(message)); // This is where the error occurs
  }

I have a simple ruby script running on my server that accepts the handshake and handles some stuff based off of the message received. The server shows a handshake working properly, but doesn't receive a message due to the client giving me a strange error. It was working fine until today. What may have caused my application to fail?




Aucun commentaire:

Enregistrer un commentaire