Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
496 views
in Technique[技术] by (71.8m points)

node.js - H15 on Heroku SSE request

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:

  1. What do I need to do in order to keep this thing going? An HTTP header parameter? Something on the client JS side? How do I avoid H15?
  2. Am I trying to do something not supported by Heroku? I don't think so, as I have another app on Heroku that uses EventSource successfully (express-eventsource.herokuapp.com, source on github: https://github.com/TravelingTechGuy/express-eventsource)

As always, thanks for your time.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:

  1. Not everything is a code issue - if it works well in one environment and not in another, it's a configuration issue
  2. If you struggle with something for too long, it helps to bring in a new set of eyes. Even with no subject matter expertise, you'll get great ideas to fresh approaches you can try
  3. 1and1 DNS control sucks b@lls. Moving out of there

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...