[英]How to handle Azure App Service WebSockets timeout?
I have 2 app services instances set up in Azure, with one connecting to the other through a WebSocket connection.我在 Azure 中设置了 2 个应用服务实例,其中一个通过 WebSocket 连接连接到另一个。 Some of the connections are long-running (multiple minutes) as the processing takes time.
由于处理需要时间,一些连接需要长时间运行(几分钟)。 After approx.
大约后。 2 minutes and a few seconds (I assume it's about the 230 second idle timeout Azure has) the connections time out with ECONNTIMEDOUT.
2 分几秒(我假设它大约是 230 秒空闲超时 Azure 有)连接超时与 ECONNTIMEDOUT。 Is there any way to circumvent this with WebSockets?
有没有办法用 WebSockets 来规避这个问题? Locally, everything works as expected.
在本地,一切都按预期工作。
The Azure apps have an 'idle timeout.' Azure 应用程序具有“空闲超时”。 According to Microsoft, this is usually between 4 and 30 minutes long, after this time, your client's connection is removed.
根据 Microsoft 的说法,这通常在 4 到 30 分钟之间,在此之后,您的客户端的连接将被删除。
Apparently, this is configurable.显然,这是可配置的。
You should be able to go into the app's config settings ie, app.config for app service and change the idle timeout property on any endpoints you have open on the app like so.您应该能够 go 进入应用程序的配置设置,即应用程序服务的 app.config 并更改您在应用程序上打开的任何端点上的空闲超时属性,如下所示。
Ex:前任:
<InputEndpoint name="MyEndpoint" protocol="tcp" localPort="80" port="80" idleTimeoutInMinutes="30" />
If its an ASP.Net (Framework) app you can setup a heartbeat message to push down the WebSocket to keep the connection open.如果它是一个 ASP.Net(框架)应用程序,您可以设置一个心跳消息来下推 WebSocket 以保持连接打开。 .net core also has something similar I believe.
我相信 .net 内核也有类似的东西。
You can use the HttpRuntime.Cache to set this up really easily as Jeff Atwood explains on the Stackoverflow Blog: https://stackoverflow.blog/2008/07/18/easy-background-tasks-in-aspnet/正如 Jeff Atwood 在 Stackoverflow 博客上解释的那样,您可以使用 HttpRuntime.Cache 非常轻松地进行设置: https://stackoverflow.blog/2008/07/18/easy-background-tasks-in-aspnet/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.