Blazor 服务器端 - AWS 环境中频繁出现 504 错误

2024-05-02

通过 AWS Elastic Beanstalk 将 blazor 服务器端项目部署到 Amazon Web Services 环境后,该网站经常断开连接,我不明白。

测试时这些断开连接不会在本地发生。

Errors:

[2020-04-30T16:29:18.326Z] Error: Connection disconnected with error 'Error'.

and

Failed to load resource: the server responded with a status of 504 ()

导致 504 错误的请求具有如下标头:

Request URL: https://mywebserver/_blazor?id=UOPQELxzuEcaGbpNUQA01Q&_=1588264098305
Request Method: GET
Status Code: 504 
Remote Address: 3.11.236.203:443
Referrer Policy: no-referrer-when-downgrade
content-length: 550
content-type: text/html
date: Thu, 30 Apr 2020 16:29:20 GMT
server: awselb/2.0
status: 504
:authority: mywebserver
:method: GET
:path: /_blazor?id=UOPQELxzuEcaGbpNUQA01Q&_=1588264098305
:scheme: https
accept: */*
accept-encoding: gzip, deflate, br
accept-language: en-GB,en-US;q=0.9,en;q=0.8
content-type: text/plain;charset=UTF-8
sec-fetch-dest: empty
sec-fetch-mode: cors
sec-fetch-site: same-origin
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36
x-requested-with: XMLHttpRequest

此问题似乎与此处发布的 Github 问题非常相似,微软目前正在调查该问题,尽管此问题与 AWS 无关:https://github.com/dotnet/aspnetcore/issues/19094 https://github.com/dotnet/aspnetcore/issues/19094

任何帮助将不胜感激!


我最终设法解决了这个问题。

显然这个问题是由使用 LongPolling 引起的。 LongPolling 发出请求并等待 100 秒后再取消请求。通过在我的 AWS 设置中将弹性负载均衡器中的超时设置为大于默认值 60 秒,断开连接就会停止。建议将 110 秒作为安全超时值。

我为感兴趣的人打开了 Asp.NET github 上的问题:https://github.com/dotnet/aspnetcore/issues/21369 https://github.com/dotnet/aspnetcore/issues/21369

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Blazor 服务器端 - AWS 环境中频繁出现 504 错误 的相关文章

随机推荐