Current location: Hot Scripts Forums » General Web Coding » HTML5 » WebSocket Help!-Hello Chrome users


WebSocket Help!-Hello Chrome users

Reply
  #1 (permalink)  
Old 02-22-11, 08:31 AM
Derrick Joseph Derrick Joseph is offline
New Member
 
Join Date: Feb 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation WebSocket Help!-Hello Chrome users

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.
Reply With Quote
  #2 (permalink)  
Old 02-25-11, 09:17 AM
Derrick Joseph Derrick Joseph is offline
New Member
 
Join Date: Feb 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
The error was with the header from the server. Notice the "/" after the server ip and port(server). And the "/" on the websocket object definition after the port.

"Sec-WebSocket-Location: ws://my server ip:8080" + "/\r\n" (server)
websocket = new WebSocket('ws://my server ip:8080/'); (client)

The client java script should be modified as
websocket = new WebSocket('ws://My server IP here:8080/'); (Notice the "/")
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
winform read and write users vinyl3 ASP.NET 2 06-13-09 10:53 AM
Select users from database zoliky Database 2 08-14-06 04:15 PM
best way to log in users, and keep them logged in nassau PHP 15 01-16-06 05:13 PM
require bb users to fill out questionnaire altlprsn Script Requests 0 01-26-05 04:06 PM
Users Registration System postyourweb PHP 3 07-23-04 08:34 AM


All times are GMT -5. The time now is 09:30 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.