Client initiated graceful close causes 995 Windows error (connection forcibly closed) #1484
Unanswered
stavikpetr
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello. I have a issue related to the closing of a websocket connection gracefully from the client side while using boost::beast client, because each close attempt results in 995 windows socket error, which means that the connection was forcibly closed on the remote side.
boost version: 1.74
uwebsockets version: 18.17.0 (I also tried the newest version)
To give you a little bit more details, the client is asynchronous and it uses the powerfull boost::asio library in combination with already mentioned boost::beast library. Basically, in the client, I have one thread that is processing all of the asynchronous events in the
boost::asio::io_context::run
method. Theio_context
has always one read callback enqueued, that is processing the messages from the server, and its main part looks like this:Receiving the messages and sending them works perfectly fine. However, when another thread intiates the shutdown by performing
boost::beast::websocket::stream<boost::asio::ip::tcp::socket>>::async_close
, I should receive, according to the documentation, the error codeboost::beast::websocket::error::closed
which indicates clear shutdown. However, instead of that, I always receive the 995 error code. I checked some other examples on the client, and I dont think the issue is in it.So, I also checked the server, and after some debugging, it seems that the issue is in this part of code, in file
WebSocketContext.h
:More precisely, after the call to
asyncSocket->shutdown()
, the client receives the aforementioned 995 error and nothing else.Can anybody please try to help, or at least point me in the right direction? From my limited understanding of the code, it seems that the socket is closed before the shutdown is called, which causes this error. This would be supported by the fact, that when the graceful close is initiated from the server side (after some inactivity), everything is fine, because the socket is not corked and this part of code in the
end()
function sends the shutdown right after sending the close frame (fileWebSocket.h
)Any help is highly appreciated, because currently I am kinda lost on what to do with this. I can provide more details if necessary. And sorry for a long post.
EDIT:
So, I did some additional investigation and I tried to create basically a minimalist reproducible example so it can clearly ilustrate the issue I have in mind. Below, you can see a very simple client and server and I still got the same error even in this case. What is the issue? Any ideas? It just seems that I can not read anything from the websocket client after I send the close event.
Client code
Server code
Beta Was this translation helpful? Give feedback.
All reactions