H15上Heroku SSE请求 [英] H15 on Heroku SSE request

查看:99
本文介绍了H15上Heroku SSE请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Heroku上有一个Node.js应用程序。我最近切换了一个长查询来使用SSE(EventSource)。虽然它在我的机器上运行得非常好,但我仍然在我的GET请求中收到 Error H15(空闲连接)。 H15的描述说我每次交易的时间超过了55秒。但是我的整个查询不会超过4-5秒。 然后,在阅读描述之后,我在返回第一个字节(只是一个数字)后立即返回查询,在它开始繁重的工作之前 - 它仍然



我的问题是:


  1. 为了让这件事情继续下去,我需要做些什么?一个HTTP头参数?在客户端JS方面的东西?我该如何避免H15?

  2. 我正在尝试做一些Heroku不支持的功能吗?我不这么认为,因为我在Heroku上有另一个成功使用EventSource的应用程序( express-eventsource.herokuapp.com ,源于github: https://github.com/TravelingTechGuy/express-eventsource

与往常一样,感谢您的宝贵时间。

解决方案

在尝试了所有事情之后,更改并重写我的代码,分析网络等等,最后我的朋友(没有任何Node知识)提出了一个让我走上正轨的想法: p>

看起来这是一个域问题 - 根本不是代码问题。

我设置了ANAME映射,事实证明,由于Heroku使用5不同的IP,只映射到其中一个可能导致SSE呼叫。基本上,mydomain.com显示的IP与mydomain.herokuapp.com不同 - 意味着服务器试图返回不同于发起呼叫的IP的响应,因此超时。



我放弃了ANAME而转而使用CNAME(基本上放弃了裸露的mydomain.com,转而使用www.mydomain.com),现在它似乎正在发挥作用。



结论:


  1. 并非所有事情都是代码问题 - 如果它在一个环境中运行良好而不在另一个环境中运行,配置问题

  2. 如果您遇到过长时间的问题,有助于引入新的眼睛。即使没有专业知识,您也可以通过全新的方式获得很棒的想法,您可以尝试
    <1> 1and1 DNS控制吸收b @ lls。搬出去


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.

解决方案

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

这篇关于H15上Heroku SSE请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆