6

I am looking to start a HTML5 WebSockets project and I was just wondering what you think the best back-end would be for that sort of thing? So far in my research I've stumbled across the following:

  • PHP Back-end (apparently a "Hack" and only compatible with Chrome and webkit nightlies)
  • Java Back-end (Seems well documented and cross-browser compatible)
  • Ruby Back-end (Don't know much about ruby, any opinions?)
  • JavaScript Library (Seems like it would be a nightmare, any opinions?)

Does anyone know of any other options or have an opinion on the above? My only requirements are ease of set-up and easy back end programmibility for bidirectional communication. I would essentially like to access a database through WebSockets and am looking for the easiest way to do this. Any feedback would be appreciated.

pimvdb
  • 151,816
  • 78
  • 307
  • 352
SuperTron
  • 4,203
  • 6
  • 35
  • 62
  • This answer to a question of the WebSockets FAQ seems quite verbose: http://stackoverflow.com/questions/1253683/what-browsers-support-html5-websocket-api/2700609#2700609. – pimvdb Nov 03 '11 at 18:14
  • There is a nice list there yes, but I would like an opinion on what is the best solution for ease of set up and use. Also, sorry about the "" around URLS, apparently my new account doesn't like me posting more than 2 URLs :( – SuperTron Nov 03 '11 at 18:16
  • Personally I prefer JavaScript but of course it depends what language you're after. Using Node.js you can fairly easily set it up (for Windows there is just one binary file which doesn't need any installations and which you can directly run). I've never used a library for WebSockets though, because I wanted to fiddle around as to creating the handshake etc myself, so I cannot give an opinion on that. Nevertheless, Node.js has turned out to be quite usable. – pimvdb Nov 03 '11 at 18:52
  • I found this article usefull : http://www.codeproject.com/Articles/733297/WebSocket-libraries-comparison – Thomas May 17 '16 at 15:36

2 Answers2

5

Ease of setup would have to be a hosted solution which uses WebSockets, HTTP Streaming or HTTP Long-Polling (one of which I work for). They're the easiest option because you don't need to spend time installing your solution, configuring it and working out how to use in when developing and in production.

If you are looking for a self hosted solution then it really depends on what technology you'd prefer to use and what the community for that technology is like.

  • Node.js and socket.io has a big community following at the moment so it wouldn't be a bad choice.
  • PHP - I'm afraid that PHP isn't really build with long-held persistent connections in mind. So, although there are options it's probably best to either use a hosted service or steer clear.
  • Ruby - check out Faye (also has node.js option), Juggernaut or Cramp
  • Java: As you say, jwebsocket or WaterSpout Server

Hope this helps.

zenbeni
  • 7,019
  • 3
  • 29
  • 60
leggetter
  • 15,248
  • 1
  • 55
  • 61
  • Socket.IO implementing client cannot talk to a non-Socket.IO based WebSocket or Long Polling Comet server. Therefore Socket.IO requires using the Socket.IO libraries on both client and server side. So it is build on top of websocket, and once you choose it, you can't swap it for another implementation : you are then bond to socket IO for the best, ... and the worst! – Thomas May 17 '16 at 15:11
  • My point is: Socket.IO is NOT a Websocket server, so it is not compatible with a Websocket client. – Thomas May 17 '16 at 15:31
  • On what basis do you say that PHP isn't build for long-held persistent connections? – TheStoryCoder Dec 11 '16 at 21:39
3

I 'd recommend websocketd http://websocketd.com/ It 's a thin layer you can wrap around any program that reads from stdin and writes to stdout and transform it to a websocket server.

So you can write in any language you like. Afterwards just

$ websocketd --port=8080 my-program

and you have your server.