title: AndroidAsync websockets not working
body: <p>I am using this <a href="https://github.com/koush/AndroidAsync" rel="noreferrer">AndroidSync</a> library by koush to to create websocket (server/client) and transfer data between two android devices. The two devices are connected via wifi(one is Wifi AP and other is connected to it ). I get TimeoutException in client device after 4-5 sec of sending the request.
  This is what I have done so far..</p>
  
  <p><strong>ServerActivity.java</strong></p>
  
  <pre><code> protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_server);
  
      mSockets = new ArrayList&lt;WebSocket&gt;();
      mAsyncHttpServer = new AsyncHttpServer();
      mWebSocketCallback = new AsyncHttpServer.WebSocketRequestCallback() {
          @Override
          public void onConnected(final WebSocket webSocket, RequestHeaders headers) {
              mSockets.add(webSocket);
              webSocket.send("Welcome Client");
              webSocket.setClosedCallback(new CompletedCallback() {
                  @Override
                  public void onCompleted(Exception ex) {
                      try {
                          if (ex != null)
                              Log.e("WebSocket", "Error");
                      } finally {
                          mSockets.remove(webSocket);
                      }
                  }
              });
              webSocket.setStringCallback(new WebSocket.StringCallback() {
                  @Override
                  public void onStringAvailable(String s) {
                      Log.d("SERVERTAG",s);
                      Toast.makeText(getApplicationContext(),s,Toast.LENGTH_SHORT).show();
                  }
              });
          }
      };
  
      mAsyncHttpServer.websocket("/",mWebSocketCallback);
      mAsyncHttpServer.listen(Utils.PORT_NUMBER);
  
      Button sendButton = (Button) findViewById(R.id.sendButtonS);
      sendButton.setOnClickListener(new View.OnClickListener(){
          @Override
          public void onClick(View view) {
              for(WebSocket socket : mSockets) {
                  socket.send("Server sent a string");
              }
          }
      });
  
  }
  </code></pre>
  
  <p><strong>ClientActivity.java</strong></p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_client);
      mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
  
      //Resolve IP address
      int ipAddress = mWifiManager.getConnectionInfo().getIpAddress();
      String hostAddress = Formatter.formatIpAddress(ipAddress);
      hostAddress = "http://" + hostAddress + ":" +Utils.PORT_NUMBER;
      Log.d("CLIENTTAG", "address is " + hostAddress);
  
      mWebSocketConnectCallback = new AsyncHttpClient.WebSocketConnectCallback() {
          @Override
          public void onCompleted(Exception ex, WebSocket webSocket) {
              if (ex != null) {
                  ex.printStackTrace();
                  return;
              }
              webSocket.send("Hello Server");
              webSocket.setStringCallback(new WebSocket.StringCallback() {
                  @Override
                  public void onStringAvailable(String s) {
                      Log.d("CLIENTTAG",s);
                      Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show();
                  }
              });
          }
      };
      mAsyncHttpClient = AsyncHttpClient.getDefaultInstance();
      mAsyncHttpClient.websocket(hostAddress, null, mWebSocketConnectCallback);
  
  }
  </code></pre>
  
  <p>This is what I get in logcat in client device.</p>
  
  <pre><code>10-21 19:50:49.289      742-945/com.haloappstudio.musichub W/System.err﹕ java.util.concurrent.TimeoutException
  10-21 19:50:49.289      742-945/com.haloappstudio.musichub W/System.err﹕ at com.koushikdutta.async.http.AsyncHttpClient$2.run(AsyncHttpClient.java:240)
  10-21 19:50:49.289      742-945/com.haloappstudio.musichub W/System.err﹕ at com.koushikdutta.async.AsyncServer.lockAndRunQueue(AsyncServer.java:683)
  10-21 19:50:49.289      742-945/com.haloappstudio.musichub W/System.err﹕ at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:700)
  10-21 19:50:49.289      742-945/com.haloappstudio.musichub W/System.err﹕ at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:608)
  10-21 19:50:49.289      742-945/com.haloappstudio.musichub W/System.err﹕ at com.koushikdutta.async.AsyncServer.access$700(AsyncServer.java:37)
  10-21 19:50:49.289      742-945/com.haloappstudio.musichub W/System.err﹕ at com.koushikdutta.async.AsyncServer$13.run(AsyncServer.java:557)
  </code></pre>
  
  <p>I haven't really done socket programming before. Can anyone please help me out here?</p>
  
  <p>Any help is appreciated.</p>