njh / EtherCard

EtherCard is an IPv4 driver for the ENC28J60 chip, compatible with Arduino IDE
https://www.aelius.com/njh/ethercard/
GNU General Public License v2.0
1.03k stars 455 forks source link

TCP Connection does not close on remote FIN when persistTcpConnection is true #383

Open inf265 opened 4 years ago

inf265 commented 4 years ago

I used persistTcpConnection(true) with browseUrl but when the data is coming from the server with a FIN+PUSH, ethercard does not close the connection resulting in retries from the server to close the connection. tcpdump below. I think even if persistTcpConnection is true, the connection should be closed from ethercard when it is closed by remote side. If you have the same opinion, just tell me I already have a fix I can push upstream. BR Frédéric-Philippe Metz

09:54:44.874410 IP 192.168.1.26.2830 > XXX.80: Flags [S], seq 11776, win 768, options [mss 550], length 0
E..,..@.@.H.....>q..............`...Z......&..
09:54:44.912830 IP XXX.80 > 192.168.1.26.2830: Flags [S.], seq 3380473103, ack 11777, win 29200, options [mss 1460], length 0
E..,..@.7.Q.>q...........}......`.r.0.........
09:54:44.913513 IP 192.168.1.26.2830 > XXX.80: Flags [.], ack 1, win 1024, length 0
E..(..@.@.H.....>q...........}..P.............
09:54:44.914345 IP 192.168.1.26.2830 > XXX.80: Flags [P.], seq 1:99, ack 1, win 1024, length 98
E.....@.@.Hf....>q...........}..P.......GET /config?data=1000X30X1X2100X50Z1993X1 HTTP/1.0
Host: bla
Accept: text/html

09:54:44.952377 IP XXX.80 > 192.168.1.26.2830: Flags [.], ack 99, win 29200, length 0
E..(.C@.7...>q...........}.....cP.r.H4........
09:54:44.959559 IP XXX.80 > 192.168.1.26.2830: Flags [P.], seq 1:18, ack 99, win 29200, length 17
E..9.D@.7..r>q...........}.....cP.r..V..HTTP/1.0 200 OK

09:54:44.961109 IP 192.168.1.26.2830 > XXX.80: Flags [P.], ack 18, win 1024, length 0
E..(.D@.@.v.....>q.........c.}.!P....+........
09:54:44.961955 IP XXX.80 > 192.168.1.26.2830: Flags [FP.], seq 18:167, ack 99, win 29200, length 149
E....E@.7.~.>q...........}.!...cP.r.....Content-Type: application/json
Content-Length: 20
Server: xyz
Date: Tue, 28 Jan 2020 08:54:38 GMT

"1000X30X1X2100X50"

09:54:44.977848 IP 192.168.1.26.2830 > XXX.80: Flags [P.], ack 167, win 1024, length 0
E..(.E@.@.v.....>q.........c.}..P.............
09:54:45.263050 IP XXX.80 > 192.168.1.26.2830: Flags [FP.], seq 167, ack 99, win 29200, length 0
E..(.F@.7...>q...........}.....cP.r.G.........
09:54:45.717764 IP XXX.80 > 192.168.1.26.2830: Flags [FP.], seq 167, ack 99, win 29200, length 0
E..(.G@.7...>q...........}.....cP.r.G.........
09:54:46.693542 IP XXX.80 > 192.168.1.26.2830: Flags [FP.], seq 167, ack 99, win 29200, length 0
E..(.H@.7...>q...........}.....cP.r.G.........
09:54:48.604907 IP XXX.80 > 192.168.1.26.2830: Flags [FP.], seq 167, ack 99, win 29200, length 0
E..(.I@.7..~>q...........}.....cP.r.G.........
09:54:52.452911 IP XXX.80 > 192.168.1.26.2830: Flags [FP.], seq 167, ack 99, win 29200, length 0
E..(.J@.7..}>q...........}.....cP.r.G.........