Pergunta

Recently Heroku changed how their websockets work. My MeteorJS app now fails to connect when I set the dyno slider to 2 or more. This is the error I get in the browser console:

POST http://name.herokuapp.com/sockjs/414/ye3xmaq8/xhr_send 404 (Not Found) 

I don't specifically need the performance of 2 dyno's, I just can't have the long time delay that occurs with 1 dyno after it goes to sleep.

Foi útil?

Solução

As Slava mentioned Heroku doesn't currently have Sticky Sessions so having more than one Dyno will not work. Without Sticky Sessions subsequent requests from the same client will go to different servos and Meteor stores publication state on the server so this doesn't work.

There is a solution to your specific problem of the Dyno going to sleep. First go to your app and then select "+ Get Add-ons" at the bottom, then search for "Heroku Scheduler." This addon will let you run a scheduled task. If that scheduled task is a 'curl' to your Heroku server every ten minutes or so then the Dyno won't go to sleep because it is seeing traffic (even though its form within heroku :)

The scheduled command might look like this:

curl http://www.yourHerokuAppUrl.com/ -s > /dev/null

Select a 1x dyno and a frequency of 'every 10 minutes' and you won't have the latency issues caused by waiting for the dyno to come back from sleeping.

Outras dicas

Just to update the answer.

Heroku supports session affinity (or sticky sessions) since April 2015, and you can use many dynos on your Meteor app

Just enable it with

$ heroku labs:enable http-session-affinity
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top