I have a Node.js application on Heroku. I've recently switched a long query to use SSE (EventSource). While it works great and fast on my machine, I keep getting an Error H15 (Idle connection)
on my GET request. The H15 description says I went over 55 seconds allowed per transaction. But my entire query doesn't take more than 4-5 seconds.
Furthermore, after reading the description, I'm returning my first byte (just a number) immediately upon hitting the query, before it starts any heavy work - and it still doesn't work.
My question/s are:
As always, thanks for your time.
After trying everything, changing and re-writing my code, profiling the network etc., finally my friend (with no Node knowledge whatsoever) came up with an idea that put me on the right track:
It seems like this is a domain issue - NOT a code issue at all.
I set an ANAME mapping and it turns out that since Heroku uses 5 different IPs, mapping to just one of them can screw up an SSE call. Basically, mydomain.com showed an IP different than mydomain.herokuapp.com - meaning the server tried returning a response to a different IP than the one that initiated the call, hence it timed out.
I ditched the ANAME in favor of a CNAME (basically, giving up the naked mydomain.com in favor of www.mydomain.com) and now it seems to be working.
Conclusions:
I have run into the same problem with a Meteor application. All of a sudden every interaction returned a websocket error on the application and a h15 error on the heroku. I have resolved it by changing the root url to a naked domain, and then forwarding the naked domain to a www.example.com. Hope this would also help someone. I also totaly agree with @TravelingTechGuy on
Not everything is a code issue - if it works well in one environment and not in another, it's a configuration issue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With