I'm working on a websocket application. I have a server that is written in C#. I have tested it using another C# application for sending and receiving data. The problem occurs when I use a Java script on the chrome developer tool and use Websockets to connect to my server.

1. I receive the header string from the websocket script, with two keys and the last 8 characters for hashing.

2. I used the header string keys to generate a hash code and crate a header to send back to chrome(j script on the developer tool).

Issues:-

1. the onopen event is never triggered and the websocket does not receive the header(I assume). I use the onerror to capture any errors. Which never occur.

2. The readystate on the websocket is 0 or 2(always).

* But when I send a disconnect response from the server, the websocket triggers the onclose method. (So I assume that he was open but not ready to communicate)

Any suggestions??????? Here's the J script if it helps.


websocket = new WebSocket('ws://My server IP here:8080');

try{
websocket.onopen = function(evt)
{
open(evt)
//websocket.send("Message to send");
alert("Message is sent...");
}
}
catch(err)
{
debug(err,'error')
}

websocket.onerror = function(evt)
{
error(evt)
}

websocket.onclose = function(evt)
{
close(evt)
}

websocket.onmessage = function(evt)
{
message(evt)
}


function open(evt)
{
alert("CONNECTED");
doSend("WebSocket rocks");
}

function error(evt)
{
alert (evt.data)
}


function close(evt)
{
alert("DISCONNECTED");
}

function message(evt)

{
alert(evt.data);
}


function doSend(message)
{
alert(message);
websocket.send(message);
}



Thanks everyone.