Skip to content

Commit 29468bf

Browse files
committed
Consider all client-initiated closes to be close_reason_normal.
If any errors occur while closing, such as TLS Short Read, we don't want to reconnect if we had initiated the close.
1 parent 725a8e0 commit 29468bf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/internal/sio_client_impl.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ namespace sio
406406
void client_impl::on_close(connection_hdl con)
407407
{
408408
LOG("Client Disconnected." << endl);
409+
con_state m_con_state_was = m_con_state;
409410
m_con_state = con_closed;
410411
lib::error_code ec;
411412
close::status::value code = close::status::normal;
@@ -421,7 +422,11 @@ namespace sio
421422
m_con.reset();
422423
this->clear_timers();
423424
client::close_reason reason;
424-
if(code == close::status::normal)
425+
426+
// If we initiated the close, no matter what the close status was,
427+
// we'll consider it a normal close. (When using TLS, we can
428+
// sometimes get a TLS Short Read error when closing.)
429+
if(code == close::status::normal || m_con_state_was == con_closing)
425430
{
426431
this->sockets_invoke_void(&sio::socket::on_disconnect);
427432
reason = client::close_reason_normal;

0 commit comments

Comments
 (0)