title: Socket.io auto disconnect in Android
body: <p>I'm using socket.io in Android.I successfully connected my android application in node.js server.Everything is perfect ,but i try to create connection on Sturtup ,but socket automatically disconnected
  This is my source</p>
  
  <pre><code>public class AutoRunService extends BroadcastReceiver {
  private static Socket socket;
  @Override
  public void onReceive(Context context, Intent intent) {
      if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
          Toast.makeText(UApplication.getInstance(), "Application is ready to  open ", Toast.LENGTH_SHORT).show();
          seSocketConnection(context);
  
      }
  }
  
  
  public void seSocketConnection(final Context context) {
      try {
  
          socket = IO.socket("http://192.168.101.139:8080");
          socket.on("onconnect", new Emitter.Listener() {
  
                      @Override
                      public void call(Object... args) {
                          JSONObject obj = new JSONObject();
                          Log.e("AutoRunService", "onconnect");
  
                          try {
                              obj.put("host", "************");
                              obj.put("entity", new DeviceManager(UApplication.getInstance()).getDeviceId());
                              socket.emit("initialize", obj);
  
                          } catch (JSONException e) {
                              e.printStackTrace();
                          }
  
                      }
                  }
          ).on("onerror", new Emitter.Listener() {
  
                      @Override
                      public void call(Object... args) {
                          Log.e("AutoRunService", "onerror");
  
  
                      }
                  }
          ).on("device", new Emitter.Listener() {
  
                      @Override
                      public void call(Object... args) {
                          Log.e("AutoRunService", "device");
  
                          Intent i = new Intent(context, WelcomeImageActivity.class);
                          i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                          context.startActivity(i);
  
  
                      }
                  }
          ).on(Socket.EVENT_CONNECT_ERROR, new Emitter.Listener() {
  
              @Override
              public void call(Object... args) {
                  Log.e("AutoRunService", "EVENT_CONNECT_ERROR");
              }
  
  
          }).on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
  
              @Override
              public void call(Object... args) {
                //  socket.disconnect();
                  Log.e("AutoRunService", "EVENT_DISCONNECT");
  
              }
  
          });
          socket.connect();
  
      } catch (URISyntaxException e) {
          e.printStackTrace();
          Log.e("AutoRunService", e.toString());
  
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Manifest source code</p>
  
  <pre><code> &lt;receiver
          android:name=".AutoRunService"
          android:enabled="true"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  </code></pre>
  
  <p>o course,i have internet connection permission in manifest.I don't know what is a wrong in my source.As i said socket connection working perfect in Activity
  How i can solve my problem?
  Thanks</p>