title: Cordova Socket io xhr poll error
body: <p>i am having trouble making a connection between socket.io server and socket.io client in apache cordova application. It just won't connect to server which i run in node.js.</p>
  
  <p>My socket.io server code is as follows:</p>
  
  <pre><code>var server = require('http').createServer();
  var io = require('socket.io')(server);
  
  io.on('connection', function(socket) {
      console.log('socket connected');
  
      socket.on('disconnect', function () {
          console.log('socket disconnected');
      });
  
      socket.emit('text', 'wow. such event. very real time.');
  });
  
  server.listen(3000);
  </code></pre>
  
  <p>My cordova js code is as follows:</p>
  
  <pre><code>document.addEventListener("deviceready", onDeviceReady, false);
  function onDeviceReady() {
      console.log("Hello from app 1234");
      var socket = io('http://localhost:3000', {reconnect: true});
      console.log("socket created");
      socket.on('connect', function() {
          console.log("Connection created!");
          alert("connection ok");
          socket.on('text', function(text) {
              alert(text);
          });
      });
  }
  </code></pre>
  
  <p>When i execute it locally in my browser with cordova serve, it runs fine.
  Also it's fine when i'm doing a regular XMLHttpRequest() to any server, i tested it and was able to receive JSON just fine.</p>
  
  <p>Errors:</p>
  
  <pre><code>"socket.io-client:manager connect_error +49ms"
  "engine.io-client:socket socket error %j +50ms",Error: xhr poll error
  "socket.io-client:manager connect attempt will timeout after %d     +113ms",20000
  "engine.io-client:polling-xhr xhr poll +5s"
  "engine.io-client:polling-xhr xhr data %s +1ms",null
  "engine.io-client:socket setting transport %s +110ms","polling"
  "engine.io-client:polling-xhr xhr open %s: %s +28ms","GET","http://localhost:3000/socket.io/?EIO=2&amp;transport=polling&amp;t=1481551911376-8"
  </code></pre>
  
  <p>What could be my issue and how could i debug it further?</p>
  
  <p>EDIT: I am testing it on emulator with <code>cordova emulate android</code></p>