views:

30929

answers:

19
+32  Q: 

WebSocket for HTML5

I am going to develop an instant messaging application that runs in the browser.

What browsers support the WebSocket API?

+11  A: 

The latest versions of browsers have support for the WebSocket API today. Here are the common browsers that support it:

  • Apple Safari (in current stable release)
  • Google Chrome (in current stable release)
  • Mozilla Firefox (in version 4, in beta testing as of this writing)

Microsoft claim that Internet Explorer 9 will have support for the WebSocket API at release. There is a public snapshot build of Opera with WebSocket support available to download, and WebSockets are promised for the 10.70 release.

If you're looking for better legacy support have a look at the "Comet" model. There are frameworks today that make its implementation simpler, such as Nitrogen. Have a look at their chat room example.

You may also want to keep an eye on Google App Engine, which with its Channel API (soon available) will support the Comet model with a Web Sockets API interface, meaning that your client-side code won't need to know whether the server is communicating via open HTTP requests or web sockets. You can probably port their interface for use with your own server architecture too.

Blixt
Which technologically leading browser would that be?
Anne
Here is information about the implementation of the Web Sockets API in Mozilla browsers: https://bugzilla.mozilla.org/show_bug.cgi?id=472529 And here is information about the implementation in WebKit browsers: https://bugs.webkit.org/show_bug.cgi?id=27490 I believe you can try these features with a nightly build of either browsers.
Blixt
On second thought it's very possible that you have to patch the code yourself to get the functionality. In any case, I wouldn't go about using it even for experimental web sites for another couple of months at least.
Blixt
Ok, so you know about the same as me then :-)
Anne
@Blixt can you provide a link to the rumor that IE 9 will support WebSockets? I've searched in depth and also have been listening for any mention of this and I've heard nothing about that.
kanaka
+1  A: 

You can also download Kaazing Enterprise Gateway - http://www.kaazing.com

Jonas
I should add that the Kaazing Gateway provides an emulation layer for browsers as far back as IE 5.5 - in case you are stuck on a really old browser and can't upgrade :) This will allow you to code against the Web Socket APIs and automatically fall forward when more browsers provide Websocket support natively. If you don't want to use HTML/JavaScript the Gateway also comes with support for Silverlight, Flash, Java, and JavaFX. For reading you can go here - http://tech.kaazing.comCheers and Happy New Year -
Jonas
A: 

I'm afraid the only place you're going to find WebSocket support is in the trunk builds of Firefox at the moment. And as far as I know, the work there is still in progress. WebKit browsers (Safari & Chrome, for example) are just getting started on their implementations and they are not even available in the nightly builds.

Kelly Norton
A: 

Jabbers BOSH protocol seems to fit instant messaging very well. Give strophe a try with a server supporting BOSH such as ejabberd.

Alexander Kellett
+2  A: 

Currently no browser supports Web Sockets. Also, Web Sockets is two standalone specifications, and no longer part of HTML5: http://www.w3.org/TR/websockets/ and http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol

Anne
+2  A: 

js.io implements WebSockets for most browsers, using Orbited. (however, the site is currently down).

Using js.io, you can develop your app right now using the WebSocket API. And when browser will implement WebSockets natively, you'll get more performances.

Philippe
+26  A: 

chromium now supports websockets

http://blog.chromium.org/2009/12/web-sockets-now-available-in-google.html

Seth
+8  A: 

There is a beautiful example how to use websockets: http://armstrongonsoftware.blogspot.com/2009/12/comet-is-dead-long-live-websockets.html

Works for me in WebKit and Chrome with some minor tweaks in Joe's code.

dimavs
+5  A: 

node.js is a server side JavaScript implementation. There exist several node.js implementations of WebSocket. This allows you to have JavaScript to JavaScript communication.

http://github.com/ncr/node.ws.js

http://github.com/alexanderte/websocket-server-node.js

http://github.com/Guille/node.websocket.js/

http://github.com/zimbatm/nodejs-http-websocket

Sembiance
+20  A: 

A good workaround for those browsers that don't yet have native WebSocket support is with this implementation that uses flash to provide WebSocket support to JavaScript:

http://github.com/gimite/web-socket-js

This allows you to just code to WebSocket, and for browsers that have native support it'll use that. Otherwise it falls back to using flash for the support.

Sembiance
+1  A: 

Try http://jwebsocket.googlecode.com

narup
A: 

We are keeping an up-to-date list of WebSocket supporting browsers on our Java WebSocket project website: http://jwebsocket.org/browsers.htm

DrCoPe
I forgot to mention, we will have an applet bridge soon and at some point a flash bridge as well in order to support all browsers...
DrCoPe
+24  A: 
Cbe317
+1 for keeping it up to date. Opera [will also have Websockets support](http://my.opera.com/core/blog/websockets) in 10.70.
musicfreak
Right, I think they renamed Opera 10.70 in Opera 11 http://www.opera.com/browser/next/
Cbe317
A: 

My WebSockets example works with Safari and Chrome on Mac. Firefox 4 Beta can't open the connection, on Windows it sometimes work with Chrome :)

http://bohuco.net/blog/2010/07/html5-websockets-example/

DerFichtl
+4  A: 

socket.io and node.js is awesome Look at my multi-rooms chat demo

http://chat.solisoft.net

BONNAURE Olivier
+1  A: 

You can also use Hookbox which falls back to long-polling if websocket support is unavailable in the browser.

http://hookbox.org

http://bitshaq.com/2010/07/30/a-simple-experiment-with-hookbox/

Salman Haq
A: 

HI,

http://html5test.com/

look under communication.hope this help.

alien
A: 

The best site for HTML5 and related functionality is http://caniuse.com

kanaka
A: 

Opera 11 will support WebSockets based on the 76 draft, one can test it out with the current 10.70 alpha:
http://my.opera.com/desktopteam/blog/2010/10/11/websockets

Ivo Wetzel