Links2004 / arduinoWebSockets

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

Fatal Exception in handleHeader() #472

Closed AyurM closed 2 years ago

AyurM commented 5 years ago

This problem happens when ESP8266 tries to establish websocket client connection with ESP8266 websocket server. Server is in SoftAP mode, debug port "Serial" is selected and debug level is "CORE + WI-FI + HTTP_UPDATE + UPDATER + OTA + OOM". Here is serial port debug output from server:

station: bc:dd:c2:9d:79:5e join, AID = 1
wifi evt: 5
wifi evt: 9
wifi evt: 9
wifi evt: 9
WS:ac
:ref 1
WS:av
:ref 2
:ur 2
[WS-Server][0] new client from 192.168.4.16
:rn 242
[WS-Server][0][handleHeader] RX: GET / HTTP/1.1
[WS-Server][0][handleHeader] RX: Host: 192.168.4.15:81
[WS-Server][0][handleHeader] RX: Connection: Upgrade
[WS-Server][0][handleHeader] RX: Upgrade: websocket
[WS-Server][0][handleHeader] RX: Sec-WebSocket-Version: 13
[WS-Server][0][handleHeader] RX: Sec-WebSocket-Key: K4JTWHiG7UFd4uMclHf59A==
[WS-Server][0][handleHeader] RX: Sec-WebSocket-Protocol: arduino
[WS-Server][0][handleHeader] RX: Origin: file://
[WS-Server][0][handleHeader] RX: User-Agent: arduino-WebSocket-Client
:c0 1, 242
[WS-Server][0][handleHeader] Header read fin.
[WS-Server][0][handleHeader]  - cURL: /
[WS-Server][0][handleHeader]  - cIsUpgrade: 1
[WS-Server][0][handleHeader]  - cIsWebsocket: 1
[WS-Server][0][handleHeader]  - cKey: K4JTWHiG7UFd4uMclHf59A==
[WS-Server][0][handleHeader]  - cProtocol: arduino
Fatal exception 28(LoadProhibitedCause):
epc1=0x4021115c, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000

Exception (28):
epc1=0x4021115c epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: cont 
sp: 3ffffac0 end: 3fffffd0 offset: 01a0

>>>stack>>>
3ffffc60:  feefeffe 3ffffd53 fe3020fe feefeffe  
3ffffc70:  4010377a 0000007f 7fffffff 4020f968  
3ffffc80:  3ffffdb0 3ffe8304 3ffffd10 4020b911  
3ffffc90:  401025fb 3ffffd52 3ffffcc0 4020b911  
3ffffca0:  00000000 3fff17d4 00000000 3ffffd10  
3ffffcb0:  4020f968 3ffffdb0 3ffffd52 4020bccc  
3ffffcc0:  00000001 3ffffd81 3ffffcf0 4020bccc  
3ffffcd0:  3ffe8304 00000000 0000000a 3ffea90c  
3ffffce0:  3ffffd53 3ffea05e 00000000 000000a5  
3ffffcf0:  000000a5 00ff0000 ff000000 3ffea080  
3ffffd00:  00000000 3ffe8304 3ffffdb0 4020fdc8  
3ffffd10:  00000000 ffffffff 00000000 00000000  
3ffffd20:  00000001 0000002d 00302073 00000000  
3ffffd30:  40201d9d 00000030 00000004 ffffffff  
3ffffd40:  402021a6 00000000 00000073 007f8000  
3ffffd50:  0030007e 6000001c 00000030 3ffffd29  
3ffffd60:  00000080 3ffffe60 00000000 3ffffe82  
3ffffd70:  3ffffee0 3ffffeb0 00000010 00000001  
3ffffd80:  3ffea07f 00000020 00000002 00000000  
3ffffd90:  00000020 40101232 40001e65 3fffff70  
3ffffda0:  3fff0b10 3ffe8304 00000040 4020d7b1  
3ffffdb0:  3ffffe8d 00000000 00000012 ffff0208  
3ffffdc0:  3ffffe60 0000003f 00000010 ffffffff  
3ffffdd0:  4010060b 00000001 3fff28b0 000002d6  
3ffffde0:  00323432 00000048 ff000000 00000000  
3ffffdf0:  40103579 00040000 7fffffff 00000000  
3ffffe00:  00000053 40103576 3fff0d10 00000046  
3ffffe10:  0000002c 00000047 3fff0d10 4010060b  
3ffffe20:  00000424 00000008 3fff0608 4020d7f4  
3ffffe30:  3ffffee0 3ffffeb0 00000008 00000033  
3ffffe40:  3fff0b10 00000008 3ffffe60 402091bc  
3ffffe50:  40001f46 0000000b 0000002c 402094c4  
3ffffe60:  2d53575b 76726553 5b5d7265 685b5d30  
3ffffe70:  6c646e61 61654865 5d726564 202d2020  
3ffffe80:  74784563 69736e65 3a736e6f 69756420  
3ffffe90:  000a6f6e 486c634d 41393566 000a3d3d  
3ffffea0:  3ffffee0 3ffffeb0 00000008 3ffe9140  
3ffffeb0:  40002514 3fffdd3c 00000000 00000000  
3ffffec0:  6000001c 00000033 0000000c 00000000  
3ffffed0:  3ffea050 000000f2 3ffffeb0 3ffffee0  
3ffffee0:  3fff0d10 000003f3 000003f3 3fffff70  
3ffffef0:  3fff0b10 3fff05d0 3fff0608 40208da7  
3fffff00:  3fff26fc 0000000c 3fff31c4 40218bfc  
3fffff10:  3ffe9134 00000001 000000f2 4021472d  
3fffff20:  0000000a 3fff273c 3fff26fc 402049a4  
3fffff30:  0000000a 3fff273c 0000000a 40204a12  
3fffff40:  0000000a 3fff273c 3fff273c 4020972f  
3fffff50:  3fffdad0 3fff0bd4 3fffff70 000000cc  
3fffff60:  3fff0a04 3fff05d0 3fff0608 4020901f  
3fffff70:  3fff287c 0000000f 00000000 40205d4d  
3fffff80:  4020ad40 00000000 00001388 3fff0bd4  
3fffff90:  3fffdad0 00000000 3fff05d0 4020907d  
3fffffa0:  00000000 00000000 3fff0bce 40203572  
3fffffb0:  3fffdad0 00000000 3fff0bce 4020a4f0  
3fffffc0:  feefeffe feefeffe 3ffe85f0 40100a49  
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(3,7)

load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
vbb28d4a3
~ld

Decoded stack: Imgur

This exception doesn't happen when debugging is disabled in Websockets.h: //#define DEBUG_WEBSOCKETS(...) DEBUG_ESP_PORT.printf(__VA_ARGS__)

JimSchofield commented 3 years ago

FWIW, I had this exact issue when I had a malformed printf in my WStype_CONNECTED handler

AyurM commented 2 years ago

Error was caused by this line in WebSocketsServer.cpp: DEBUG_WEBSOCKETS("[WS-Server][%d][handleHeader] - cExtensions: %s\n", client->num, client->cExtensions.c_str());