[2.0] Websockets not working with Firefox

472 views
Skip to first unread message

Tom Bocklisch

unread,
Jan 31, 2012, 5:19:41 AM1/31/12
to play-framework
Hey,

I am trying to setup a websocket connection. It's working fine in
chrome, but not in firefox. Here is the relevant code:

route.conf:
...
GET /ws controllers.DataWS.data()
...

Javascript:
...
_WebSocket = window['MozWebSocket'] ? MozWebSocket : WebSocket;
this.loadSocket = new _WebSocket("ws://" + document.location.host + "/
ws");
...

As I said in chrome this works just fine, but firefox doesn't open a
connection but shows a 404 error in console for "http://localhost:9000/
ws". Is there any way to get websockets working in firefox?

Best regards,
Tom

Nicolas Leroux

unread,
Jan 31, 2012, 5:22:21 AM1/31/12
to play-fr...@googlegroups.com
Hi,

I will have a look at it tonight as I plan to refactor it to use Netty 3.3 websocket support. Can you try with only the MozWebSocket object in the meantime?

Nicolas

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>

Tom Bocklisch

unread,
Jan 31, 2012, 5:27:45 AM1/31/12
to play-fr...@googlegroups.com
Yes I have already tried that. You can use the scala websocket-chat example to reproduce the error. You need to change the JavaScript call from WebSocket to MozWebSocket in chatroom.scala.html line 32.

Best regards,
Tom

Nicolas Leroux

unread,
Jan 31, 2012, 5:30:43 AM1/31/12
to play-fr...@googlegroups.com
One last question, which firefox version are you using? I tested with firefox 7 if I recall correctly.

Nicolas
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/_OPey3z1RjkJ.

Tom Bocklisch

unread,
Jan 31, 2012, 5:32:13 AM1/31/12
to play-fr...@googlegroups.com
I have tested it with the 11.0a2 aurora version and the 9 / 10 stable versions.

Tom Bocklisch

unread,
Feb 5, 2012, 4:36:52 PM2/5/12
to play-fr...@googlegroups.com
I have examined it a little more. When opening the websocket chrome sends the following request:

ws://localhost/ws -
Connection:
Upgrade - and the server returns a 101 Switching protocols


but firefox request goes to

http://localhost/ws
- Connection:
Upgrade - and the server returns a 404


I guess the pattern matching of play lacks this "feature" of firefox ( this is NOT connected to the JS I am using. In both cases the WebSocket URL specified in JS is the same ). Could you please fix that?

Regards,

Tom

Tom Bocklisch

unread,
Feb 7, 2012, 7:05:52 AM2/7/12
to play-fr...@googlegroups.com
Hey Nicolas,

I have found the bug. Its more of a Firefox bug then a play one because FF doesn't follow the web socket handshake protocol. Nevertheless I guess the small fix I have suggested in the issue resolves that and should be included.


Best regards,
Tom

-- 
Tom Bocklisch

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/j1g17UAf69IJ.

Nicolas Leroux

unread,
Feb 7, 2012, 7:28:12 AM2/7/12
to play-fr...@googlegroups.com
Thank you very much

Nicolas
Reply all
Reply to author
Forward
0 new messages