title: Connecting to NodeJS on Heroku with Socket.io
body: <p>I'm in the early stages of developing a multiplayer game on Android Studio and I decided to use NodeJS for the server development and host it on Heroku. The game client would then connect to the node server that is hosted on Heroku but it doesn't seem to working when I run the application on my phone. How can I find the correct connection url to achieve a proper connection with the heroku server?  </p>
  
  <p>Index.js        </p>
  
  <pre><code>var app = require('express')();
  var server = require('http').Server(app);
  var io = require('socket.io')(server);
  
  
  server.listen(8080, function(){
      console.log("Server running...");
  });
  
  io.on('connection', function(socket){ 
      console.log("Player connected.");
      socket.on('disconnect', () =&gt; console.log('Player disconnected'));
  });
  </code></pre>
  
  <p>Main Activity in Android Studio (Socket Connection method)</p>
  
  <pre><code> private Socket socket;
   public void connectSocket(){
      try{
        socket = IO.socket("http://localost:8080");
        socket.connect();
      }catch(Exception e){
        System.out.println(e);
      }
    }
  </code></pre>