Skip to content

Commit 4ba4ac9

Browse files
committed
WSocket comment out log messages
1 parent 487034c commit 4ba4ac9

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/AsyncWSocket.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ void WSocketClient::_clientSend(size_t acked_bytes){
219219
//log_d("infl:%u, credits:%u", _in_flight, _in_flight_credit);
220220
// check if we were waiting to ack our disconnection frame
221221
if (!_in_flight && (_connection == conn_state_t::disconnecting)){
222-
log_d("closing tcp-conn");
222+
//log_d("closing tcp-conn");
223223
// we are server, should close connection first as per https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.1
224224
// here we close from the app side, send TCP-FIN to the party and move to FIN_WAIT_1/2 states
225225
_client->close();
@@ -244,7 +244,7 @@ void WSocketClient::_clientSend(size_t acked_bytes){
244244
// ignore the call if available sock space is smaller then acked data and we won't be able to fit message's ramainder there
245245
// this will reduce AsyncTCP's event Q pressure under heavy load
246246
if ((_outFrame.msg && (_outFrame.len - _outFrame.index > _client->space())) && (_client->space() < acked_bytes) ){
247-
log_d("defer ws send call, in-flight:%u/%u", _in_flight, _client->space());
247+
//log_d("defer ws send call, in-flight:%u/%u", _in_flight, _client->space());
248248
return;
249249
}
250250

@@ -362,12 +362,12 @@ void WSocketClient::_onTimeout(uint32_t time) {
362362

363363
void WSocketClient::_onDisconnect(AsyncClient *c) {
364364
_connection = conn_state_t::disconnected;
365-
log_d("TCP client disconnected");
365+
//log_d("TCP client disconnected");
366366
_sendEvent(event_t::disconnect);
367367
}
368368

369369
void WSocketClient::_onData(void *pbuf, size_t plen) {
370-
Serial.printf("_onData, len:%u\n", plen);
370+
//log_d("_onData, len:%u\n", plen);
371371
if (!pbuf || !plen || _connection == conn_state_t::disconnected) return;
372372
char *data = (char *)pbuf;
373373

@@ -405,7 +405,7 @@ void WSocketClient::_onData(void *pbuf, size_t plen) {
405405

406406
// if we got whole frame now
407407
if (_inFrame.index == _inFrame.len){
408-
log_d("_onData, cmplt msg len:%u", (uint32_t)_inFrame.len);
408+
//log_d("cmplt msg len:%u", (uint32_t)_inFrame.len);
409409

410410
if (_inFrame.msg->getStatusCode() == 1007){
411411
// this is a dummy/corrupted message, we discard it
@@ -417,7 +417,7 @@ void WSocketClient::_onData(void *pbuf, size_t plen) {
417417
// received close message
418418
case WSFrameType_t::close : {
419419
if (_connection == conn_state_t::disconnecting){
420-
log_d("recv close ack");
420+
//log_d("recv close ack");
421421
// if it was ws-close ack - we can close TCP connection
422422
_connection = conn_state_t::disconnected;
423423
// normally we should call close() here and wait for other side also close tcp connection with TCP-FIN, but
@@ -432,7 +432,7 @@ void WSocketClient::_onData(void *pbuf, size_t plen) {
432432
}
433433

434434
// otherwise it's a close request from a peer - echo back close message as per https://datatracker.ietf.org/doc/html/rfc6455#section-5.5.1
435-
log_d("recv client's ws-close req");
435+
//log_d("recv client's ws-close req");
436436
{
437437
#ifdef ESP32
438438
std::unique_lock<std::recursive_mutex> lockin(_inQlock);
@@ -488,6 +488,7 @@ std::pair<size_t, uint16_t> WSocketClient::_mkNewFrame(char* data, size_t len, W
488488
// read frame size
489489
frame.len = data[1] & 0x7F;
490490
size_t offset = 2; // first 2 bytes
491+
/*
491492
Serial.print("ws hdr: ");
492493
//Serial.println(frame.mask, HEX);
493494
char buffer[10] = {}; // Buffer for hex conversion
@@ -499,7 +500,7 @@ std::pair<size_t, uint16_t> WSocketClient::_mkNewFrame(char* data, size_t len, W
499500
++ptr;
500501
}
501502
Serial.println();
502-
503+
*/
503504
// find message size from header
504505
if (frame.len == 126 && len >= 4) {
505506
// two byte
@@ -513,7 +514,7 @@ std::pair<size_t, uint16_t> WSocketClient::_mkNewFrame(char* data, size_t len, W
513514
offset += 8;
514515
}
515516

516-
log_d("recv hdr, sock data:%u, msg body size:%u", len, frame.len);
517+
//log_d("recv hdr, sock data:%u, msg body size:%u", len, frame.len);
517518

518519
// if ws.close() is called, Safari sends a close frame with plen 2 and masked bit set. We must not try to read mask key from beyond packet size
519520
if (masked && len >= offset + 4) {
@@ -609,7 +610,7 @@ std::pair<size_t, uint16_t> WSocketClient::_mkNewFrame(char* data, size_t len, W
609610
_inFrame.index = bodylen;
610611
}
611612

612-
log_e("new msg frame size:%u, bodylen:%u", offset, bodylen);
613+
//log_e("new msg frame size:%u, bodylen:%u", offset, bodylen);
613614
// return the number of consumed data from input buffer
614615
return {offset, 0};
615616
}
@@ -734,9 +735,6 @@ void WSocketServer::handleRequest(AsyncWebServerRequest *request) {
734735
const AsyncWebHeader *key = request->getHeader(WS_STR_KEY);
735736
AsyncWebServerResponse *response = new AsyncWebSocketResponse(key->value(), [this](AsyncWebServerRequest *r){ return newClient(r); });
736737
if (response == NULL) {
737-
#ifdef ESP32
738-
log_e("Failed to allocate");
739-
#endif
740738
request->abort();
741739
return;
742740
}
@@ -831,7 +829,6 @@ WSocketServer::msgall_err_t WSocketServer::messageToEndpoint(uint32_t hash, WSMe
831829
}
832830

833831
void WSocketServer::_purgeClients(){
834-
log_d("purging clients");
835832
std::lock_guard lock(clientslock);
836833
// purge clients that are disconnected and with all messages consumed
837834
_clients.remove_if([](const WSocketClient& c){ return (c.connection() == WSocketClient::conn_state_t::disconnected && !c.inQueueSize() ); });
@@ -885,7 +882,7 @@ bool WSocketServerWorker::newClient(AsyncWebServerRequest *request){
885882
#endif
886883
_clients.emplace_back(getNextId(), request,
887884
[this](WSocketClient *c, WSocketClient::event_t e){
888-
log_d("client event id:%u state:%u", c->id, c->state());
885+
//log_d("client event id:%u state:%u", c->id, c->state());
889886
// server echo call
890887
if (e == WSocketClient::event_t::msgRecv) serverEcho(c);
891888
if (_task_hndlr) xTaskNotifyGive(_task_hndlr);

0 commit comments

Comments
 (0)