Skip to content

Commit 0ffa665

Browse files
committed
Websocket is not stopping now, remove check that websocket needs to have a connection
Signed-off-by: Maaike Zijderveld <m.zijderveld@alfen.nl>
1 parent c90a0c4 commit 0ffa665

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

lib/ocpp/common/websocket/websocket_plain.cpp

+8-10
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,14 @@ void WebsocketPlain::close(websocketpp::close::status::value code, const std::st
257257
websocketpp::lib::error_code ec;
258258
this->cancel_reconnect_timer();
259259

260-
if (this->is_connected()) {
261-
this->ws_client.stop_perpetual();
262-
this->ws_client.close(this->handle, code, reason, ec);
263-
if (ec) {
264-
EVLOG_error << "Error initiating close of plain websocket: " << ec.message();
265-
// on_close_plain won't be called here so we have to call the closed_callback manually
266-
this->closed_callback(websocketpp::close::status::abnormal_close);
267-
} else {
268-
EVLOG_info << "Closed plain websocket successfully.";
269-
}
260+
this->ws_client.stop_perpetual();
261+
this->ws_client.close(this->handle, code, reason, ec);
262+
if (ec) {
263+
EVLOG_error << "Error initiating close of plain websocket: " << ec.message();
264+
// on_close_plain won't be called here so we have to call the closed_callback manually
265+
this->closed_callback(websocketpp::close::status::abnormal_close);
266+
} else {
267+
EVLOG_info << "Closed plain websocket successfully.";
270268
}
271269
}
272270

lib/ocpp/common/websocket/websocket_tls.cpp

+9-11
Original file line numberDiff line numberDiff line change
@@ -445,17 +445,15 @@ void WebsocketTLS::close(websocketpp::close::status::value code, const std::stri
445445
websocketpp::lib::error_code ec;
446446
this->cancel_reconnect_timer();
447447

448-
if (this->is_connected()) {
449-
this->wss_client.stop_perpetual();
450-
this->wss_client.close(this->handle, code, reason, ec);
451-
452-
if (ec) {
453-
EVLOG_error << "Error initiating close of TLS websocket: " << ec.message();
454-
// on_close_tls wont be called here so we have to call the closed_callback manually
455-
this->closed_callback(websocketpp::close::status::abnormal_close);
456-
} else {
457-
EVLOG_info << "Closed TLS websocket successfully.";
458-
}
448+
this->wss_client.stop_perpetual();
449+
this->wss_client.close(this->handle, code, reason, ec);
450+
451+
if (ec) {
452+
EVLOG_error << "Error initiating close of TLS websocket: " << ec.message();
453+
// on_close_tls wont be called here so we have to call the closed_callback manually
454+
this->closed_callback(websocketpp::close::status::abnormal_close);
455+
} else {
456+
EVLOG_info << "Closed TLS websocket successfully.";
459457
}
460458
}
461459

0 commit comments

Comments
 (0)