How to use network sockets

I am trying to use Easy Websockets to come up with a chat application.

Here is the code I have right now. As you can see, I am trying to log a message to the console every time I hit the submit button. It works when I open it on two browsers. But it only works for less than 1 minute.

<input type="text" id="txt"/>
<input type="button" value="send" id="sends"/>
<div id="messages"></div>

<script src="jquery171.js"></script>
<script src="easywebsockets.js"></script>   
    var socket = new EasyWebSocket("ws://");//I do not understand this part
    socket.onopen   = function(){
        socket.send("hello world.")
    socket.onmessage= function(event){

        var txt = $('#txt').val()


I got this error log from firebug:

enter image description here

I don't quite understand what this all means. Is there something I need to set up to make this work?


source to share

1 answer

This usually happens when the client is not using the same version of the protocol as the server. The server should indicate which version it is using, comes with RFC6455 by default, but it can be overridden to go with the old hybi-0x.

So check the following:

  • client and server versions of the protocol
  • origin (e.g. localhost) resolved by server
  • firewalls, internet security kits, zonealarms, stuff like that


All Articles