Links2004 / arduinoWebSockets

arduinoWebSockets
GNU Lesser General Public License v2.1
1.9k stars 555 forks source link

esp32 wss disconnects randomly with errors #873

Open UserNulled opened 9 months ago

UserNulled commented 9 months ago

esp32 wroom devkit c platformIO

arduinoWebSockets : 2.4.1 - using insecure mode ( was using 2.4.0 but same error happened )

[ esp32 --- nginx proxy (ssl) --- node.js socket ]

I am connecting esp32 to node.js websocket server via nginx wss proxy, it connects well and performs well but it disconnects randomly with errors.

[send_ssl_data():382]: (-27648) SSL - Internal error (eg, unexpected failure in lower-level module)

when using websocket (not wss) I get no errors.

While connecting (not error just Headers) :

8:14:18.528 > [WS-Client][sendHeader] sending header... Done (32498us). 18:14:18.582 > [WS-Client][handleHeader] RX: HTTP/1.1 101 Switching Protocols 18:14:18.591 > [WS-Client][handleHeader] RX: Server: nginx 18:14:18.630 > [WS-Client][handleHeader] RX: Date: Sat, 17 Feb 2024 09:14:18 GMT 18:14:18.642 > [WS-Client][handleHeader] RX: Connection: upgrade 18:14:18.651 > [WS-Client][handleHeader] RX: Upgrade: websocket 18:14:18.690 > [WS-Client][handleHeader] RX: Sec-WebSocket-Accept: y/Lyzej/RjYBEceWcpxcz4t/7Bk= 18:14:18.702 > [WS-Client][handleHeader] RX: Sec-WebSocket-Protocol: arduino 18:14:18.768 > [WS-Client][handleHeader] Header read fin. 18:14:18.771 > [WS-Client][handleHeader] Client settings: 18:14:18.775 > [WS-Client][handleHeader] - cURL: / 18:14:18.777 > [WS-Client][handleHeader] - cKey: y04+pAAwnatlbY2/5Lk/NQ== 18:14:18.783 > [WS-Client][handleHeader] Server header: 18:14:18.786 > [WS-Client][handleHeader] - cCode: 101 18:14:18.788 > [WS-Client][handleHeader] - cIsUpgrade: 1 18:14:18.794 > [WS-Client][handleHeader] - cIsWebsocket: 1 18:14:18.797 > [WS-Client][handleHeader] - cAccept: y/Lyzej/RjYBEceWcpxcz4t/7Bk= 18:14:18.889 > [WS-Client][handleHeader] - cPr otocol: arduino 18:14:18.892 > [WS-Client][handleHeader] - cExtensions: 18:14:18.894 > [WS-Client][handleHeader] - cVersion: 0 18:14:18.900 > [WS-Client][handleHeader] - cSessionId: 18:14:18.906 > [WS-Client][handleHeader] Websocket connection init done. 18:14:18.911 > [WS][0][headerDone] Header Handling Done.

Error Messages :

18:18:19.641 > [WS][0][sendFrame] ------- send message frame ------- 18:18:19.643 > [WS][0][sendFrame] fin: 1 opCode: 1 mask: 1 length: 40 headerToPayload: 0 18:18:19.652 > [WS][0][sendFrame] text: {"type":6,"data":{"temp":264,"hum":403}} 18:18:19.657 > [WS][0][sendFrame] pack to one TCP package... 18:18:19.660 > [write] n: 46 t: 243710 18:18:19.669 > [WS][0][sendFrame] sending Frame Done (7276us). 18:18:19.672 > [WS-Client] sending HB ping 18:18:19.675 > [WS][0][sendFrame] ------- send message frame ------- 18:18:19.681 > [WS][0][sendFrame] ------- send message frame ------- 18:18:19.684 > [WS][0][sendFrame] fin: 1 opCode: 1 mask: 1 length: 29 headerToPayload: 0 18:18:19.692 > [WS][0][sendFrame] text: {"type":7,"data":{"lux":106}} 18:18:19.694 > [WS][0][sendFrame] pack to one TCP package... 18:18:19.700 > [WS][0][sendFrame] fin: 1 opCode: 9 mask: 1 length: 0 headerToPayload: 0 18:18:19.706 > [write] n: 6 t: 243755 18:18:19.709 > [write] n: 35 t: 243757 18:18:19.715 > [243763][E][ssl_client.cpp:37] _handle_error(): [send_ssl_data():382]: (-27648) SSL - Internal error (eg, unexpected failure in lower-level module) 18:18:19.726 > [WS][0][sendFrame] sending Frame Done (8873us). 18:18:19.732 > WS write 0 failed left 35! 18:18:19.735 > [WS-Client] connection lost. 18:18:19.735 > [WS-Client] client disconnected. 18:18:19.738 > [ws] Disconnected! 18:18:19.741 > [write] not connected! 18:18:19.747 > [WS][0][sendFrame] sending Frame Done (35788us).

Error Message 2 :

21:52:20.556 > [WS][0][sendFrame] sending Frame Done (4526us). 21:52:20.561 > [WS][0][sendFrame] ------- send message frame ------- 21:52:20.565 > [WS][0][sendFrame] fin: 1 opCode: 1 mask: 1 length: 28 headerToPayload: 0 21:52:20.574 > [WS][0][sendFrame] text: {"type":7,"data":{"lux":37}} 21:52:20.578 > [WS][0][sendFrame] pack to one TCP package... 21:52:20.581 > [write] n: 34 t: 5306550 21:52:20.586 > [WS][0][sendFrame] sending Frame Done (4024us). 21:52:21.644 > [WS-Client] sending HB ping 21:52:21.647 > [WS][0][sendFrame] ------- send message frame ------- 21:52:21.652 > [WS][0][sendFrame] fin: 1 opCode: 9 mask: 1 length: 0 headerToPayload: 0 21:52:21.658 > [write] n: 6 t: 5307627 21:52:21.663 > [WS][0][sendFrame] sending Frame Done (3974us). 21:52:21.669 > [5307637][E][ssl_client.cpp:37] _handle_error(): [data_to_read():361]: (-29184) SSL - An invalid SSL record was received 21:52:21.678 > [5307637][E][ssl_client.cpp:37] _handle_error(): [data_to_read():361]: (-29184) SSL - An invalid SSL record was received 21:52:21.689 > [WS-Client] connection lost. 21:52:21.692 > [WS-Client] connection lost. 21:52:21.694 > [WS-Client] client disconnected. 21:52:21.697 > [WS-Client] client disconnected. 21:52:21.700 > [ws] Disconnected!

KevinNelSL commented 3 months ago

@UserNulled, Did you ever resolve this?