Websocket Connection with EG800K

Good day,

I’m currently developing a project using LTE cellular connectivity. I chose to use the EG800K module, however, I’m facing some issues. I would like to open a TCP connection and then upgrade the connection into a websocket connection. I managed to open the connection successfully, and even upgrade the connection using transparent transmission mode. In spite of this, I need to be able to send AT commands while the connection is open (CMUX behavior), so I couldn’t use this approach because the ESP32 needs to take over the UART as the frames are sent and received through the UART directly, and I would need to send the escape sequence ‘+++’ to go back to command mode. So then, I explored the other two modes, buffer access mode and direct push mode. Even though I completed the approach and managed to open the connection in both modes, I wasn’t able to go any further because everything comes through the URC messages handler and it starts to ‘collapse’ by appending messages that had already been read. Here is an example of what happens:

First URC Message:

[09:42:37.205] W (18:50:23.186) ESP_MODEM: URC received:
[09:42:37.215] +QSSLURC: "recv",1
[09:42:37.225]

Second URC Message:

The +QSSLURC: “recv”,1 is in the URC message again even though it’s already been read.

[09:42:38.123] W (18:50:24.257) ESP_MODEM: URC received: 
[09:42:38.135] +QSSLURC: "recv",1
[09:42:38.146] 
[09:42:38.157] +QSSLRECV: 402
[09:42:38.167] HTTP/1.1 101 Switching Protocols
[09:42:38.178] Connection: upgrade
[09:42:38.188] Server: nginx/1.20.1
[09:42:38.197] Date: Thu, 02 Oct 2025 07:42:37 GMT
[09:42:38.208] Upgrade: websocket
[09:42:38.218] Sec-WebSocket-Accept: r6zyLrCSQ7oG7qJpbm/KAqYXmOk=
[09:42:38.227] uWebSockets: 20
[09:42:38.238] X-Cache: Miss from cloudfront
[09:42:38.247] Via: 1.1 0bc5d0934ecfdccaa70bff2ed15f447a.cloudfront.net (CloudFront)
[09:42:38.258] X-Amz-Cf-Pop: LHR50-C1
[09:42:38.268] X-Amz-Cf-Id: jkRnJM-QMNXmBGJyP6MsmBxqhnBRTNyHkg8PG8f0RRyPLsr-cUPCDA==
[09:42:38.278] 
[09:42:38.288] 
[09:42:38.297] 
[09:42:38.307] OK
[09:42:38.316]

Third URC Message:

The +QSSLURC: “recv”,1 and +QSSLRECV: 402 HTTP/1.1 101 Switching Protocols… are in the URC message again even though they’ve already been read.

[09:43:30.205] +QSSLURC: "recv",1
[09:43:30.217] 
[09:43:30.228] +QSSLRECV: 402
[09:43:30.238] HTTP/1.1 101 Switching Protocols
[09:43:30.249] Connection: upgrade
[09:43:30.260] Server: nginx/1.20.1
[09:43:30.270] Date: Thu, 02 Oct 2025 07:42:37 GMT
[09:43:30.281] Upgrade: websocket
[09:43:30.290] Sec-WebSocket-Accept: r6zyLrCSQ7oG7qJpbm/KAqYXmOk=
[09:43:30.301] uWebSockets: 20
[09:43:30.311] X-Cache: Miss from cloudfront
[09:43:30.320] Via: 1.1 0bc5d0934ecfdccaa70bff2ed15f447a.cloudfront.net (CloudFront)
[09:43:30.331] X-Amz-Cf-Pop: LHR50-C1
[09:43:30.339] X-Amz-Cf-Id: jkRnJM-QMNXmBGJyP6MsmBxqhnBRTNyHkg8PG8f0RRyPLs
[09:43:30.350] >

So, as you can see, the messages keep on getting appended, even though they have already been read. And this behavior continues for as long as the connection to the server is open.

Does anyone have any clue of why this could be happening, or what I could do to solve this? I’m currently looking into adapting the esp-modem library to try to make it work through that route. If anyone also happens to have a custom module for the EG800K for the library, I’d be happy to have it. Any suggestions or existing examples on how to achieve this functionality would be much appreciated.

Thank you in advance to everyone.

hi ,According to the issue you described, when using the EG800K module for a TCP connection and then upgrading it to a WebSocket connection, URC messages are being processed repeatedly. Does this situation occur when using TCP alone?