Please provide the link, as it's not on this thread.meowsqueak wrote: ↑Mon Sep 16, 2019 11:20 pmDid you try the PR I linked to? I didn't have any problems with it, but my use case may be different.
tcp_server example not able to reconnect the server after disconnect
Re: tcp_server example not able to reconnect the server after disconnect
-
- Posts: 151
- Joined: Thu Jun 15, 2017 4:54 am
- Location: New Zealand
Re: tcp_server example not able to reconnect the server after disconnect
It is, but here it is again anywayblippy wrote: ↑Tue Sep 17, 2019 8:01 amPlease provide the link, as it's not on this thread.meowsqueak wrote: ↑Mon Sep 16, 2019 11:20 pmDid you try the PR I linked to? I didn't have any problems with it, but my use case may be different.
https://github.com/espressif/esp-idf/pull/3597
Re: tcp_server example not able to reconnect the server after disconnect
OK. Thanks. I'll give it a go when I have a spare ESP. All of mine are currently in-service.
Re: tcp_server example not able to reconnect the server after disconnect
OK, I've had a chance to try the proposed patch (after much fiddling around with updates).
My conclusion: it fixes the big problem everyone has been having, but still contains a bug.
The bug is this: if two clients try to connect at the same time, then the second one will block (which I think is OK, that's not the problem). However, when the first one disconnects, the second one will receive a "connection reset by peer".
The problem as I see it is that is in the wrong place. You really ought not to put it there! It closes the listening socket on disconnecting the first client, which means that anything that was connected to it at the time will be disconnected.
The code I presented in my previous post fixes that issue. (It may contain other problems, though.)
My conclusion: it fixes the big problem everyone has been having, but still contains a bug.
The bug is this: if two clients try to connect at the same time, then the second one will block (which I think is OK, that's not the problem). However, when the first one disconnects, the second one will receive a "connection reset by peer".
The problem as I see it is that
Code: Select all
close(listen_sock)
The code I presented in my previous post fixes that issue. (It may contain other problems, though.)
-
- Posts: 151
- Joined: Thu Jun 15, 2017 4:54 am
- Location: New Zealand
Re: tcp_server example not able to reconnect the server after disconnect
Fair enough - my workaround was a consolidation of other comments to support a single client and multiple reconnections. Two unique non-concurrent clients will need a different solution.
Re: tcp_server example not able to reconnect the server after disconnect
I think it's certainly OK to only service one connection at a time whilst keeping the others in a blocked state. Servicing multiple connections would require a much more elaborate solution, which would be too complex for the example.
Who is online
Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 99 guests