diff --git a/mongoose.c b/mongoose.c index 43e818a1..2b85e238 100644 --- a/mongoose.c +++ b/mongoose.c @@ -3032,7 +3032,8 @@ static size_t deliver_websocket_frame(struct connection *conn) { } // Call the handler and remove frame from the iobuf - if (call_user(conn, MG_REQUEST) == MG_FALSE) { + if (call_user(conn, MG_REQUEST) == MG_FALSE || + (buf[0] & 0x0f) == WEBSOCKET_OPCODE_CONNECTION_CLOSE) { conn->ns_conn->flags |= NSF_FINISHED_SENDING_DATA; } iobuf_remove(&conn->ns_conn->recv_iobuf, frame_len);