Skip to content


Getting JWebSocketServer running on linux (Ubuntu)

Mainly I develop on Ubuntu and today I wanted to get the demo of jWebSocket code working on my workstation. There were some bumps on the road, but finally I have it working. Here I’ll explain what I’ve done. This is written and tested for Ubuntu, but could also be useful for other Linux distributions.

On the jWebSocket website I went to Quick Guide -> jWebSocket Server and followed the instructions. When I came to the follwing line: “For Unix and Linux environments please type java -jar bin/jWebSocketServer-<version>.jar in the shell.”
I noticed that Flash couldn’t start. Because FlashBridge needs to listen on port 843, and nonroot users aren’t allowed to listen on ports below 1024 on Linux. I tried authbind to give permission for my user to listen on port 843, but didn’tget that to work properly.
Well, at least the server works for browsers with native support for websockets. Hoorayy!

Now get the Flashbridge working. It’s a bit of a hack, but what the hell, it works for now.
I’ve changed the listening port to 1024+ (8843 to be precise) and configured my firewall to forward port 8843 to 843. Steps to take:

  • Download the source code (I took jWebSocketFullSources-0.10.zip).
  • In FlashBridgePlugIn.java change mListenerPort to 8843
  • Make an iptables configuration with the rules to forward the port (see below, copy the rules in a file called firewall.conf).
  • As root execute: iptables-restore < firewall.conf
  • Now you can recompile the code and run JWebSocketServer.class. When you (re)start the jWebSocket server FlashBridge should work now.
*filter
:INPUT ACCEPT [2828:1111536]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [2981:383081]
COMMIT
*nat
:PREROUTING ACCEPT [272:24244]
:POSTROUTING ACCEPT [419:36692]
:OUTPUT ACCEPT [418:36632]
-A PREROUTING -i eth0 -p tcp -m tcp --dport 843 -j REDIRECT --to-ports 8843
-A OUTPUT -p tcp -m tcp --dport 843 -j REDIRECT --to-ports 8843
COMMIT

Some remarks:

  • This only worked when I serve the html files in a webserver (I now use Apache) so I can surf to http://localhost/
  • When you reboot you need to set the iptables rules again. See this page how to automate this task.

Maybe there’s a much more elegant way to get this FlashBridge working on linux, but I didn’t found one yet. For now I can at least focus on playing with jWebSockets. I must admit that I’m impressed with what I’ve seen this far!

Tagged with , , , .


0 Responses



Some HTML is OK

or, reply to this post via trackback.

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.