Search code examples
firefoxwebsocketweb-worker

WebWorkers and WebSockets with Firefox


I'm trying to implement a working WebSocket connection within a WebWorker. That should be simple and it is if I use Chrome as b rowser. However, since this experiment should further become part of a production I need it to work on all the great Browsers, namely also Firefox.

My problem is that I can't get it working with Firefox. At first Firefox wasn't able to create a WebWorker. That was a Bug and is fixed with version 9. But now it seems that it wouldn't be able to create a WebSocket within the Worker.

I tried the following line of code:

var ws = new WebSocket(url);

which fails with:

WebSocket is not defined

Well, according to this it should work. But it doesn't, neither within the WebWorker nor outside of this context. I tried the older

var ws = new MozWebSocket(url);

which seems to work outside of the WebWorker but I get the same error as above within it.

Now, what's the problem? I know WebSockets where disabled byy default in some older versions but version 9 should support a similar functionality as Chrome (at least that's what they say on their side). So am I doing something wrong?

Im using Ubuntu 11.10 and did not test other browsers yet.

Thanks in advance!


Solution

  • There's no support for WebSocket in workers in Firefox yet. See https://bugzilla.mozilla.org/show_bug.cgi?id=504553

    Update: Firefox 35 added support.