Web套接字上的Heroku H15错误关闭 [英] Heroku H15 Error on web socket close

查看:64
本文介绍了Web套接字上的Heroku H15错误关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Heroku上有一个Go服务作为Web套接字服务器.客户端每20秒对服务器执行一次ping操作,它似乎使连接保持打开状态.问题是,当套接字连接关闭时,Heroku路由器会抛出H15错误,认为该请求花费了太多时间.例如,如果Web套接字连接已打开300秒,则Heroku日志将显示:

I have a Go service serving as a web socket server on Heroku. The client pings the server every 20 seconds and it seems to keep the connection open. The problem is that when the socket connection is closed, Heroku router throws H15 error thinking that the request took too much time. For example, if web socket connection has been open for 300 seconds, Heroku log would show:

….H15…. dyno = web.1 connect = 1ms service = 300000ms status = 503字节= 147….

….H15…. dyno=web.1 connect=1ms service=300000ms status=503 bytes=147….

有人经历过吗?

推荐答案

是的!我已经遇到了这种情况,经过一些深入的调试,我得出的结论是,这只是Heroku Router引擎中的误报".我的调试是这样的:

yes! I have experienced that situation and after some deep debugging, I came to the conclusion that this is just a "false positive" in the Heroku Router engine. My debugging went like this:

  1. 在客户端和在Heroku上运行的WebSocket服务器之间创建WebSocket连接.
  2. 如果您使用的是socket.io或类似的库,则最有可能在将协议切换到WebSocket之前建立HTTP轮询连接. (您可以在Heroku Router日志中看到这些GET/POST请求.)
  3. 使用WebSocket协议建立连接后,客户端将通过发送心跳使保持连接(实际上服务器也可以这样做). 最初,您不会在Heroku Router日志中看到此请求,因为该请求仍处于待处理状态(它处于打开状态,每隔几秒钟发送一次数据包,即心跳信号).您可以使用Chrome DevTools的网络"标签对此进行监控.
  4. 心跳阻止Heroku Router终止请求,因为每次在客户端和服务器之间传输几个字节时,,其中X是从收到请求到关闭请求的时间,即当您看到这样的日志时:service=79859ms status=101
  1. Create a WebSocket connection between the client and the WebSocket server running on Heroku.
  2. If you're using socket.io or a similar library it will most likely establish an HTTP polling connection before switching protocols to WebSocket. (You can see these GET/POST requests in the Heroku Router logs).
  3. Once the connection is established using the WebSocket protocol, the client will keep it alive by sending a heartbeat (actually the server can do this too). Initially, you won't see this request in the Heroku Router logs because it's still pending (it's open and sending packages of data every few seconds, the heartbeat). You can monitor this by using the Chrome DevTools Network tab.
  4. The heartbeat prevents Heroku Router from terminating the request, since every time a few bytes are transferred between the client and the server the Heroku Router timeout timer (55secs) is reset.
  5. However, whenever your client closes the connection (ie: closes the browser tab, refreshes the page, disconnects from the internet, etc); the Heroku Router detects the request being terminated and (here comes is my guess based on debugging) because the request was "pending" it reacts as if it was idle for X amount of milliseconds, where X is the time from when the request was received until it was closed, that's when you see logs like this: service=79859ms status=101

结论:只要您的客户端应用终止WebSocket连接,Heroku Router就会记录一条错误15行,该连接在X毫秒的时间内运行良好.因此,在许多情况下,可能只是用户离开了您的应用.

As a conclusion: Heroku Router will log an Error 15 line whenever your client app terminates a WebSocket connection which was working perfectly fine for X amount of milliseconds. So, in many cases, it can be just users leaving your app.

我希望这对人们有帮助,希望你们可以少睡一会儿:)

I hope this helps people and that you guys can go to sleep with one less thing to worry about :)

这篇关于Web套接字上的Heroku H15错误关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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