title: Socket.IO with Node.js on Heroku
body: <p>I have Socket.IO set up with node.js and it works on my local development machine by listening/connecting to port 8000 (or another port that is not the port that my server is running on).</p>
  
  <p>When I try to do the same thing on heroku, my client-side script import fails.</p>
  
  <p>I have tried relative path</p>
  
  <pre><code>&lt;script src="/socket.io/socket.io.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>I have also tried to bind to port 8000 on heroku and use the full pathname     </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
           var href = document.location.protocol + document.location.hostname + ':8000/socket.io/socket.io.js';
           console.log("href = " + href);
           document.write("&lt;script src=" + href + "&gt;&lt;\/script&gt;");
       &lt;/script&gt;
  </code></pre>
  
  <p>I did read that websockets don't work on heroku, so I have the following code in my after_start.js file on the backend. Do I need to do something else in addition to configuring socket.io to use transports/polling?</p>
  
  <pre><code>var port = process.env.PORT || 8000; //I've tried hardcoding to 8000 and using process.env.PORT and then I used the relative path for the script import
  io = require('socket.io').listen(port);
  //Configue io to work with heroku
  io.configure(function () { 
      io.set("transports", ["xhr-polling"]); 
      io.set("polling duration", 10); 
  });
  </code></pre>
  
  <p>I get this error when I load my heroku app:</p>
  
  <pre><code>GET http://&lt;myAppName&gt;.herokuapp.com/socket.io/socket.io.js 404 (Not Found) 
  </code></pre>
  
  <p>Edit: I am actually using geddy mvc framework and would like to get this working how I have it set up (basically just like socket.io) on heroku and I found this answer that makes it seem like I can use it similarly:
  <a href="https://stackoverflow.com/questions/13644551/geddyjs-socket-io-catching-and-emitting-events-from-server-side#answer-13653919">GeddyJS &amp; socket.io: catching and emitting events from server side</a></p>