Suave停止响应“套接字无法接受客户端".错误 [英] Suave stops responding with "Socket failed to accept a client" error

查看:50
本文介绍了Suave停止响应“套接字无法接受客户端".错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个通过ECS在AWS上运行的应用程序(作为Docker容器),我使用Suave接收了一些REST命令.

I have an app running on AWS through ECS (as a Docker container) for which I used Suave to receive some REST commands.

代码非常原始:

let conf =
    { defaultConfig with bindings = [ HttpBinding.createSimple HTTP "0.0.0.0" 80] }

let app =
    choose
        [
            POST >=> choose
                    [
                    path "/" >=> request (fun m ->
                        // find if this is a subscription confirmation
                        let isConfirmation =
                            m.headers |> List.exists (fun kvp -> snd kvp = "SubscriptionConfirmation")

                        ... more stuff here but that's it for the Suave code

,它以:

let listening, server = startWebServerAsync conf app
server    |> Async.Start
listening |> Async.RunSynchronously |> ignore // wait for the server to start listening

Suave至少每天一次停止回复任何请求,并且日志中显示以下内容:

At least once a day, Suave stops replying to any request and I get the following in the log:

(这是屏幕截图,因为我无法从(超级烦人的)AWS的日志记录用户界面中注销文本)

(this is a screenshot because I couldn't get the text log out of the (super annoying) AWS's logging UI)

错误始终相同,这是一个测试流量很小的应用程序.但是,它每隔10秒就会从另一个应用程序收到一条ping消息.

The error is always the same, and this is an app in testing with very little traffic. However, it gets a ping message every 10s from another app.

由于这是我的第一个Suave项目,如何解决此问题?这是一个已知的问题吗?我可以做更多的日志记录来帮助解决问题吗?问题可能是由于码头工人本身造成的吗?

Since this is my first Suave project, how can I troubleshoot this? is this a known problem? is there more logging I can do to help troubleshoot it? could the issue be due to docker itself?

我决定每1分钟打印一次使用的连接:

I decided to print the connections used every 1 min:

there are 9 connections open
there are 15 connections open
there are 21 connections open
there are 26 connections open
there are 32 connections open
there are 37 connections open
there are 43 connections open
there are 49 connections open
there are 55 connections open
there are 61 connections open
there are 67 connections open

每10秒钟收到一次ping,作为POST消息.

There is a ping received, as a POST message, every 10 seconds.

我这样跟踪:

let p = IPGlobalProperties.GetIPGlobalProperties().GetTcpIPv4Statistics()
terminal.BroadcastMessage $"there are {p.CurrentConnections} connections open"

看起来连接永远不会关闭.

It looks like the connections never gets closed.

推荐答案

这只是一个猜测,但是我现在可以使用PowerShell Invoke-WebRequest 在多个终端上重现此内容.我打开的每个新终端都会导致打开的连接数增加.事实证明, Invoke-WebRequest 默认情况下使用 Keep-Alive 标头,因此我能够通过禁用此功能来解决此问题.

This is just a guess, but I'm now able to reproduce this using PowerShell Invoke-WebRequest across multiple terminals. Each new terminal I open causes the number of open connections to increase. It turns out that Invoke-WebRequest uses a Keep-Alive header by default, so I was able to fix the problem by disabling this feature.

因此,我想知道您的客户端(发送ping的东西)是否正在使用keep-alive标头,但无法重用它打开的连接.如果是这样,您可以通过在客户端中禁用保持活动来解决此问题.

Thus, I'm wondering if perhaps your client (the thing sending the ping) is using a keep-alive header, but failing to reuse the connections it opens. If so, you could fix this by disabling keep-alive in the client.

这篇关于Suave停止响应“套接字无法接受客户端".错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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