title: Socket io client in android using socket io java client
body: <p>I have a node server running. i want to connect to server with socket. i'm using socket io java client (<a href="https://github.com/Gottox/socket.io-java-client/wiki" rel="nofollow">https://github.com/Gottox/socket.io-java-client/wiki</a>) 
  here is my server code :</p>
  
  <pre><code>var app = require('express')()
   , http = require('http')
   , server = http.createServer(app)
   , io = require('socket.io').listen(server);
  io.sockets.on('connection', function(client)
  {
  console.log("client connected!");
  client.emit('messages',{text: 'Hello world!'});
  client.on('messages', function(data)
  {
      console.log(data);
  });
  client.on('echo', function(data)
  {
      console.log(data);
  });
  });
  server.listen(8080);
  </code></pre>
  
  <p>and here is my android code : </p>
  
  <pre><code>try {
          SocketIO socket = new SocketIO("http://10.0.2.2:9000/");
          socket.connect(new IOCallback() {
  
              @Override
              public void onMessage(JSONObject arg0, IOAcknowledge arg1) {
                  try {
                      Toast.makeText(MainActivity.this,
                              arg0.getString("text"), Toast.LENGTH_LONG)
                              .show();
                  } catch (JSONException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
  
              }
  
              @Override
              public void onMessage(String arg0, IOAcknowledge arg1) {
                  Toast.makeText(MainActivity.this, arg0, Toast.LENGTH_LONG)
                          .show();
  
              }
  
              @Override
              public void onError(SocketIOException arg0) {
                  Log.d("tag", arg0.toString());
  
              }
  
              @Override
              public void onDisconnect() {
                  // TODO Auto-generated method stub
  
              }
  
              @Override
              public void onConnect() {
                  Toast.makeText(MainActivity.this, "Connected",
                          Toast.LENGTH_LONG).show();
  
              }
  
              @Override
              public void on(String event, IOAcknowledge ack, Object... args) {
                  if ("echo back".equals(event) &amp;&amp; args.length &gt; 0) {
                      Log.d("SocketIO", "" + args[0]);
                      // -&gt; "hello"
                  }
              }
          });
          socket.emit("echo", "hello");
      } catch (MalformedURLException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  </code></pre>
  
  <p>my socket does not connect! i mean no toast shown in android. and here is my server log :</p>
  
  <pre><code> debug - client authorized
     info  - handshake authorized -M9Dcv2a1Gd-LJpkogRF
     debug - setting request GET /socket.io/1/websocket/-M9Dcv2a1Gd-LJpkogRF
     debug - set heartbeat interval for client -M9Dcv2a1Gd-LJpkogRF
     debug - client authorized for 
     debug - websocket writing 1::
  client connected!
     debug - websocket writing 5:::{"name":"messages","args":[{"text":"Hello world!"}]}
  hello
     info  - transport end (undefined)
     debug - set close timeout for client -M9Dcv2a1Gd-LJpkogRF
     debug - cleared close timeout for client -M9Dcv2a1Gd-LJpkogRF
     debug - cleared heartbeat interval for client -M9Dcv2a1Gd-LJpkogRF
     debug - discarding transport
  </code></pre>
  
  <p>where is my fault?</p>