Sorry, this is going to be lengthy now 
Tried first to print out the socketStatus
in EthernetClient::connected()
. I had a lot of application stuff in the Serial output - I edited the log to only show the relevant. Lines starting >>>
are remarks I added:
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5828
entry 0x400806ac
__ OK __
Resetting Wiz W5500 Ethernet Board... Done.
My IP address: 192.168.178.73
>>> Boot sequence finished. I pressed a button to fire off the first two requests. Note. No connection established yet
TCP request bridge, 20, 0x03, 0/10
TCP request bridge, 4, 0x03, 1/10
Target: 192.168.178.77/6502
Connect returns 1
>>> Connection was established, the following line stems from EthernetClient::connected() - ESTABLISHED
socketStatus=23
>>> Here followed a print-out of the returned data
Target: 192.168.178.77/6502
>>> Next request, same target. Note the missing "Connect returns...", since the app knows the previous had the same target
>>> connected() is called twice here to check the result of a potential re-connect: ESTABLISHED still
socketStatus=23
socketStatus=23
>>> Again data output removed by me
>> Next two requests sent - #3/#4:
TCP request bridge, 20, 0x03, 0/10
TCP request bridge, 4, 0x03, 1/10
>>> Target is still the same
Target: 192.168.178.77/6502
>>> A different socketStatus now: CLOSE_WAIT
socketStatus=28
>>> As reaction, another connection is opened, resulting in socketStatus==ESTABLISHED
Connect returns 1
socketStatus=23
>>> Data output removed
>>> Request #4, connection is found open (ESTABLISHED)
Target: 192.168.178.77/6502
socketStatus=23
socketStatus=23
>>Data output removed
>>> Two more requests - #5 and #6
TCP request bridge, 20, 0x03, 0/10
TCP request bridge, 4, 0x03, 1/10
>>> Request #5. Target remains the same, but socketStatus is CLOSE_WAIT again, so I open another connection
Target: 192.168.178.77/6502
socketStatus=28
Connect returns 1
socketStatus=23
>>> Data output removed
>>> Request #6, socketStatus=ESTABLISHED
Target: 192.168.178.77/6502
socketStatus=23
socketStatus=23
>>> Data output removed
>>> Next request pair #7/#8:
TCP request bridge, 20, 0x03, 0/10
TCP request bridge, 4, 0x03, 1/10
>>> Request #7: socketStatus CLOSE_WAIT
Target: 192.168.178.77/6502
socketStatus=28
>>> Re-connect is failing, as all following are.
Connect returns 0
Error: IP connection failed Token: 7
Target: 192.168.178.77/6502
Connect returns 0
Error: IP connection failed Token: 8
TCP request bridge, 20, 0x03, 0/10
TCP request bridge, 4, 0x03, 1/10
Target: 192.168.178.77/6502
Connect returns 0
Error: IP connection failed Token: 9
Target: 192.168.178.77/6502
Connect returns 0
Error: IP connection failed Token: A
The addressed target ESP32 has two connections blocked for internal reasons, so obviously the communication comes to an end as soon as the remaining 6 sockets of the W5500 are consumed.
Next I tried it with a WiFiClient
instead of the EthernetClient
. That works on and on and on.
So it really seems to be caused by the EthernetClient
not reacting correctly on remote socket closes.
I was not able to do a tcpdump unfortunately. I only have a locked FritzBox owned by my Internet provider… 