Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Socket.IO Client Implementation in Java
Java JavaScript
Latest commit 13762a3 tox Applied diff from #44


Flattr this git repo

Socket.IO-Client for Java is an easy to use implementation of for Java.

It uses Weberknecht as transport backend, but it's easy to write your own transport. See description below. An XHR-Transport is included, too. But it's not functional in its current state.

The API is inspired by


  • transparent reconnecting - The API cares about re-establishing the connection to the server when the transport is interrupted.
  • easy to use API - implement an interface, instantiate a class - you're done.
  • output buffer - send data while the transport is still connecting. No problem, handles that.
  • meaningful exceptions - If something goes wrong, SocketIO tries to throw meaningful exceptions with hints for fixing.

Status: Connecting with Websocket is production ready. XHR is in beta.

How to use

Using is quite simple. But lets see:

Checkout and compile the project:

git clone git://
ant jar
mv jar/socketio.jar /path/to/your/libs/project

If you're using ant, change your build.xml to include socketio.jar. If you're eclipse, add the jar to your project buildpath.

Afterwards, you'll be able to use this library:

        SocketIO socket = new SocketIO("");
        socket.connect(new IOCallback() {
            public void onMessage(JSONObject json, IOAcknowledge ack) {
                try {
                    System.out.println("Server said:" + json.toString(2));
                } catch (JSONException e) {

            public void onMessage(String data, IOAcknowledge ack) {
                System.out.println("Server said: " + data);

            public void onError(SocketIOException socketIOException) {
                System.out.println("an Error occured");

            public void onDisconnect() {
                System.out.println("Connection terminated.");

            public void onConnect() {
                System.out.println("Connection established");

            public void on(String event, IOAcknowledge ack, Object... args) {
                System.out.println("Server triggered event '" + event + "'");

        // This line is cached until the connection is establisched.
        socket.send("Hello Server!");

For further informations, read the Javadoc.


  • with git

    git clone git://
  • with mercurial

    hg clone 

Both repositories are synchronized and up to date.


to build a jar-file:

ant jar
ls jar/socketio.jar

You'll find the in jar/socketio.jar


Please report any bugs feature requests to the Github issue tracker


This Library was designed with portability in mind.

  • Android is fully supported.
  • JRE is fully supported.
  • GWT does not work at the moment, but a port would be possible.
  • Java ME does not work at the moment, but a port would be possible.
  • ... is there anything else out there?


There comes a JUnit test suite with Currently it's tested with Eclipse.

You need node installed in PATH.

  • open the project with eclipse
  • open tests/io.socket/
  • run it as JUnit4 test.


  • needs more unit-tests.
  • XhrTransport needs to pass all tests.
  • If websockets are failing (due to proxy servers e.g.), use XHR automaticly instead.

License - the boring stuff...

This library is distributed under MIT Licence.

Sounds so interesting...

You'll find further documentation at the Github Wiki

Something went wrong with that request. Please try again.