我试着运行Boost-Beast示例http_server_async.cpp。它运行得很好(使用了一个线程,使用了mingw64窗口,gcc 10.2),但是过了一段时间,我收到了三条消息:
read: The socket was closed due to a timeout
read: The socket was closed due to a timeout
read: The socket was closed due to a timeout我猜发生这种情况的原因是超时,在session::do_read方法中设置为30秒,如果我们将session::on_read方法中的条件修改为:
if(ec == http::error::end_of_stream || ec == beast::error::timeout) return do_close();它应该能起作用。但让我担心的是,我们有3条消息,即使只有一个请求被发送(从Chrome)。我查过了-是的,根据这个请求创建了三次会议。
所以我有几个问题:
发布于 2020-12-30 00:06:51
找到了。Chrome创建了3个连接。Firefox创建2个连接并立即关闭一个连接。如果我使用curl或我自己的客户端运行它,服务器端只接受一个连接。
https://stackoverflow.com/questions/65497829
复制相似问题