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

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

问题描述

我在 Heroku 上有一个 Node.js 应用程序.我最近将一个长查询切换为使用 SSE (EventSource).虽然它在我的机器上运行良好且速度快,但我的 GET 请求不断收到 Error H15 (Idle connection).H15 描述说我每笔交易允许超过 55 秒.但是我的整个查询不会超过 4-5 秒.

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.

我的问题是:

  1. 我需要做什么才能让这件事继续下去?HTTP 标头参数?客户端 JS 端的东西?如何避免 H15?
  2. 我是否正在尝试做 Heroku 不支持的事情?我不这么认为,因为我在 Heroku 上有另一个成功使用 EventSource 的应用程序 (express-eventsource.herokuapp.com,来自 github:https://github.com/TravelingTechGuy/express-eventsource)
  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.

推荐答案

在尝试了一切,更改和重新编写我的代码,分析网络等之后,我的朋友(完全没有 Node 知识)想出了一个主意这让我走上了正轨:

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:

这似乎是一个域问题 - 根本不是代码问题.
我设置了一个 ANAME 映射,结果证明,由于 Heroku 使用 5 个不同的 IP,因此仅映射到其中一个 IP 可能会搞砸 SSE 调用.基本上,mydomain.com 显示的 IP 与 mydomain.herokuapp.com 不同——这意味着服务器尝试向与发起呼叫的 IP 不同的 IP 返回响应,因此超时.

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.

我放弃了 ANAME,转而使用 CNAME(基本上,放弃裸 mydomain.com 以支持 www.mydomain.com),现在它似乎起作用了.

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.

结论:

  1. 并非所有事情都是代码问题 - 如果它在一种环境中运行良好,而在另一种环境中运行良好,则是配置问题
  2. 如果您为某事挣扎了太久,则有助于引入新的眼光.即使没有任何主题专业知识,您也会对可以尝试的新方法产生很好的想法
  3. 1and1 DNS 控制很糟糕 b@lls.搬出去

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

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