"Invalid url for WebSocket ws://localhost:8080/socket.io/websocket"

1,799 views
Skip to first unread message

arnorhs

unread,
Jan 12, 2011, 7:23:40 AM1/12/11
to Socket.IO
Hey guys, I'm having some problems with connecting to my server using
chrome. It actually works fine in Firefox (probably using long polling
or flash socket..?) but when I try to connect using chrome I get the
following error:

"Invalid url for WebSocket ws://localhost:8080/socket.io/websocket"

The message isn't really helping so I tried googling around, but
didn't have any luck.

Any idea what it means?

Thanks (btw. socket.io is awesome)

eschmitt

unread,
Jan 12, 2011, 10:27:32 PM1/12/11
to Socket.IO
Just a guess, but have you tried using something other than localhost
in your url?... Maybe try the fully qualified domain name, or
something like 127.0.0.1?..

Tim

unread,
Jan 13, 2011, 1:03:09 PM1/13/11
to sock...@googlegroups.com
For some reason my last post vanished, anyway...

Try opening the socket like this if you're not already:

var socket = new io.Socket('localhost', { port : 8080 });

I was having the same issue when specifying the port as localhost:8080.

Tim

unread,
Jan 13, 2011, 9:49:11 AM1/13/11
to Socket.IO
If you're calling this from your client-side Javascript as:

var socket = new io.Socket('localhost:8080');

The port needs to be specified in the options.

Change it to:

var socket = new io.Socket('localhost', { port: 8080 });

That should work.

arnorhs

unread,
Jan 13, 2011, 4:11:30 PM1/13/11
to Socket.IO
That was exactly it! Works like a charm now. Thanks Tim.

I guess I should have RTFM before I put in that port number :)

Cheers

Guillermo Rauch

unread,
Jan 13, 2011, 4:16:03 PM1/13/11
to sock...@googlegroups.com
Thanks Tim for helping him out.
I'll be adding support for URIs as the argument very soon. options#port is not exactly common or intuitive.

--
Guillermo Rauch
http://devthought.com
Reply all
Reply to author
Forward
0 new messages