SOLVED: Socket.io + heroku questions


#1

SOLVED: I solved this issue by explicitly setting the port in the url to :443 when loading the socket.io.js script. Also I downloaded the socket.io.js script and loaded it from my www/js folder instead of remotely grabbing the file.

I’m developing my ionic app locally on http://localhost:9105.
When my node.js server is running on localhost:3000 I load up socket.io as follows:

<script src="http://localhost:3000/socket.io/socket.io.js"></script>

This works great.

Now I’m ready to deploy my application and run it on heroku. So for heroku I’m doing this:

<script src="https://myapp.herokuapp.com/socket.io/socket.io.js"></script>

This will load the script.

My first question is: will this cause problems getting accepted in the app store as I’ve read that loading remote .js files can be problematic to being accepted in the ios app store.

My second question is the following: web sockets work locally, but not when running on heroku. On heroku I notice the following when emitting events through socket.io:

GET https://myapp.herokuapp.com:9105/socket.io/?EIO=3&transport=polling&t=1413741073385-39 net::ERR_CONNECTION_REFUSED 

As you can see, the port number “9105” that I use in ionic locally is somehow being injected in the url? This is definitely wrong.

I’m using angular-socket-io as a module btw.

Any help is welcome. I’m stuck pushing this to production, so thanks for helping out!


#3

I was having the exact same problem. Thanks for posting how to fix it!


#4

I’ve been there, and Heroku with socket is a pain in the ass, you can’t use more than 1 dyno! I had to fallback to timed request. :frowning: