简体   繁体   English

如何处理 Azure 应用服务 WebSockets 超时?

[英]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.

相关问题 带有websockets和AD身份验证的Azure App Service - Azure App Service with websockets and AD authentication Signalr 中的 azure 应用程序服务不适用于 websockets - Signalr in azure app service not working for websockets 如何处理 Azure 应用服务中的性能问题 - How to handle the performance issue in Azure app service Azure 应用服务:三个容器的多容器应用(如何处理) - Azure App Service : Multi container app with three containers (How to handle) 应用服务计划的 Azure 函数应用超时 - Azure function app timeout for app service plan 如何使用安全 WebSockets (wss) 在 Azure 应用服务的 Docker 容器中设置 nginx? - How to set up nginx in a Docker container in an Azure App Service with secure WebSockets (wss)? 在 Azure 应用服务上使用 WebSockets 时的权衡? - Trade-offs when using WebSockets over Azure App Service? 有关如何使用 Azure 应用服务 Linux 处理日志的建议 - Advice on how to handle logs with Azure App Service Linux 如何处理Azure App Service中长期运行的作业? - How do I handle long running jobs in Azure App Service? Azure 应用服务连接超时问题 - Azure App Service Connection Timeout Issue
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM