5

I'm starting to read about websockets, but I can't find a good WebSocket server and easy to program some examples...

I'm a complete beginner, and I don't need a server that supports a big concurrency, I just want something to try some examples...

Any Help??

Thanks!!

Andres
  • 11,439
  • 12
  • 48
  • 87
  • some tests, like a chat, a streaming of data... just to try the websockets from the client side... – Andres Oct 02 '11 at 20:37
  • @bksi, that example is a socket server. WebSockets is a protocol with a specific handshake and data framing. – kanaka Oct 02 '11 at 21:47

4 Answers4

2

Keep in mind that websockets are new technology. The most recent draft protocol has just been submitted to become the actual standard. Opera doesn't even support the latest protocol yet and Microsoft is far behind (a partial implementation said to become available in version 10 MSIE). Chrome supports it in a development version. Firefox very recently released their version 7 that supports it. Don't be surprised if you need to become part of the "development community" as an early adopter: i.e. boot-strapping your way along as tools become mature and tutorials more plentiful.

You can follow my blog. I'm creating something that seems like it's just what you're looking for and it will be distributed free to developers. Timing might be good, even though it's not ready for distribution yet. It will be integrated with parts of what's called the HLL framework that will make applications easier to develop. I'd also like to make it possible to develop back-end application components using script, including JavaScript. I've already done some work on that in the HLL framework. There's a working demonstration and you can download the dhtml / javascript client and soon a non-browser client that you can also use to build application components. The server, built in pure Sun (Oracle) Java, runs equally well on both Linux and Windows. Since it would also provide the scripting engine, application components written in script would also be portable.

The websocket server supports the latest version of the proposed protocol, which has now been submitted to become the actual websocket standard. The demo will run on Chrome dev-channel (also known as Chromium) 14 or later. Also, Firefox 7 which has now been released (no longer in Beta).

Roger F. Gay
  • 1,830
  • 2
  • 20
  • 25
  • nice work...really interesting...How hard was to program the handshake?? Because I'm really starting to consider to make my own little, very basic, small server, because I just want to send something and receive it from the clients... I don't need high concurrency or something like that... so how hard was to establish the connection? – Andres Oct 03 '11 at 11:15
  • You can read my answer to that, in response to my own question, very similar to yours when I was first getting started on the websocket server: http://stackoverflow.com/questions/6122456/simple-java-javascript-start-on-websockets/7336944#7336944 – Roger F. Gay Oct 03 '11 at 11:23
  • BTW: HLL (incl. the websocket server) is designed to be fast and light-weight. I've maintained that as a requirement all along. But I'll also have an answer when some applications need to be scaled up to handle very large traffic loads. (I'm not sure my current version will, although maybe? Not tested for that.) – Roger F. Gay Oct 03 '11 at 11:25
  • Ha you are doing the same thing i want to do... thought i was alone in the world, I've been googling for hours with no answer! I'm starting right now my own little rudimentary server, I hope i can make the handshake, thats the hard part i think... – Andres Oct 03 '11 at 11:36
  • You'll find that once you've mastered the handshake, it's far from over. :) – Roger F. Gay Oct 03 '11 at 11:59
  • I think because the word "websocket" has the word "socket" in it, people tend to think building a websocket server can be like building a simple socket server based on a one-page Java Trail tutorial. That's what I was looking for in the beginning. Far from it. – Roger F. Gay Oct 03 '11 at 12:02
  • **A note on browser support**: Chrome non-development/standard release has had support for `WebSocket` for a long time now. It's also supported on Safari (including mobile), Firefox 6 (including mobile) and up (Notes here on `MozWebSocket`: https://developer.mozilla.org/en/WebSockets), latest Opera browser and IE10 on Windows 8. The most common technique for dealing with non-supporting browsers is to simply use the [WebSocket JS Flash fallback](https://github.com/gimite/web-socket-js). The WebSocket protocol is now much less of a moving target. – leggetter Oct 03 '11 at 15:10
  • Well, but let's not create confusion. Those browsers were supporting early proposals that are now obsolete. Technically, it's hybi-10 and beyond that's relevant, and hybi-17 is what's actually been submitted to become the standard. It takes a rather long process to create a new standard or usually to update an old one. Mozilla and Google were both participants in the process, implementing and testing each proposal. Opera was also involved and I'm looking forward to their release of a hybi-10 (version 8) or beyond. At this point, they should probably just go for the standard. – Roger F. Gay Oct 03 '11 at 18:36
1

The most popular server side JavaScript framework is NodeJS, it runs best on Linux currently with a windows version in development.

http://nodejs.org/

Follow the directions for installation here:

https://github.com/joyent/node/wiki/Installation

Once you've installed Node and NPM install the socket.io package:

npm install socket.io

Then visit http://socket.io/ for am introduction to the API where you can view the server side JavaScript and the client side JavaScript.

dmck
  • 7,801
  • 7
  • 43
  • 79
  • but the problem with socket.io is that it uses an special api from the client side, I need/want to use the standard one... – Andres Oct 03 '11 at 00:24
  • As far as I can tell, node.js is pretty far behind in their support of updated protocols. True? (hybi-6?) It's also described as a "websocket compatible" http server rather than a websocket server. I'm not sure what that means. github.com/guille/node.websocket.js – Roger F. Gay Oct 03 '11 at 11:03
  • there's no direct support for WebSockets in `node.js` itself - the support mentioned here and in my answer are third party libraries. – Alnitak Oct 03 '11 at 12:09
  • Yes. I noticed that earlier. The "third party" that I noticed doing it was somehow involved in the node.js project and the package is available from websocket or ws.nodejs.com ... or something like that, a sub-directory on the node.js project server. But others have tried to add their own support as well. – Roger F. Gay Oct 03 '11 at 14:44
  • I wonder how node.js enthusiasts determine that node.js is "most popular." – Roger F. Gay Oct 07 '11 at 08:09
  • @RogerF.Gay I'm hardly a Node enthusiast, but I have used it. What I said was that Node is the most popular "server side JavaScript framework", really what other options are there that are "more popular"? – dmck Oct 07 '11 at 11:28
  • JavaScript websocket support is built into browsers. It's pretty simple. You don't need another framework. It'd say that browser support is more popular than NodeJS. – Roger F. Gay Mar 02 '12 at 10:58
0

If you are wanting a WebSocket server written in JavaScript than I suggest you look at Socket.IO. It is very simple to use, and there is lots of documentation and examples that you can find online.

If you wanting to play with a low-level WebSocket server and JavaScript is not a requirement, you might check out my python based websockify project. The websocket.py module is a generic WebSocket server framework. There are some simple examples of using it in the tests directory. Websockify itself is built on websocket.py to create a fairly sophisticated websocket to raw socket bridge/proxy.

kanaka
  • 70,845
  • 23
  • 144
  • 140
  • `Socket.IO` is _not_ a WebSocket server - it's a generic network socket communication library which can use WebSockets as a _transport_ if they're supported. – Alnitak Oct 02 '11 at 22:09
  • @Alnitak. Actually, Socket.IO **is** a WebSocket server. Yes, it's not only a WebSocket server (Apache is a web server even though it can be configured to serve other protocols such as FTP). And yes, you can configure it to use alternate transports as fallbacks, but the default/priority transport is WebSockets. And the API is similar to the WebSockets API (and in many ways based on it) but extends it with session management and other niceties. – kanaka Oct 02 '11 at 22:47
  • that's kinda my point - you have to use the special client-side `Socket.IO` object and its API. It's not "pure" WebSockets - you can't open a `ws://.../` URL directly to a `Socket.IO` server and expect the standard WebSocket API to work over it. – Alnitak Oct 02 '11 at 23:12
0

I've had good results with node.ws.js.

Do note though that it's (temporarily) incompatible with Chrome 14, because Chrome has now implemented the latest version of the IETF Hybi specification, and node.ws.js didn't catch up yet.

It works well with all version of Safari, though, including Mobile Safari.

Alnitak
  • 334,560
  • 70
  • 407
  • 495
  • As far as I can tell, node.js is pretty far behind in their support of updated protocols. True? (hybi-6?) It's also described as a "websocket compatible" http server rather than a websocket server. I'm not sure what that means. https://github.com/guille/node.websocket.js/ – Roger F. Gay Oct 03 '11 at 11:03