FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Merge pull request #58 from quentin/ws-lost-issue · luc-github/esp32_https_server@f80b961 · GitHub

Repository navigation

Commit f80b961

Browse files
authored
Merge pull request fhessel#58 from quentin/ws-lost-issue
Fix infinite loop when a Websocket connection is lost
2 parents 4e66fe5 + 46acd74 commit f80b961

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎src/HTTPConnection.cpp‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,15 @@ void HTTPConnection::loop() {
563563
HTTPS_LOGD("Calling WS handler, FID=%d", _socket);
564564
_wsHandler->loop();
565565
}
566+
567+
// If the client closed the connection unexpectedly
568+
if (_clientState == CSTATE_CLOSED) {
569+
HTTPS_LOGI("WS lost client, calling onClose, FID=%d", _socket);
570+
_wsHandler->onClose();
571+
}
572+
566573
// If the handler has terminated the connection, clean up and close the socket too
567-
if (_wsHandler->closed()) {
574+
if (_wsHandler->closed() || _clientState == CSTATE_CLOSED) {
568575
HTTPS_LOGI("WS closed, freeing Handler, FID=%d", _socket);
569576
delete _wsHandler;
570577
_wsHandler = nullptr;

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL