diff --git a/websocketpp/impl/connection_impl.hpp b/websocketpp/impl/connection_impl.hpp index 0fbc410fac..6c97998cd2 100644 --- a/websocketpp/impl/connection_impl.hpp +++ b/websocketpp/impl/connection_impl.hpp @@ -214,6 +214,10 @@ void connection::close(const close::status::value code, { m_alog.write(log::alevel::devel,"connection close"); // check state + if (m_state != session::state::OPEN) { + ec = error::make_error_code(error::invalid_state); + return; + } // check reason length if (reason.size() > frame::limits::close_reason_size) {