Good evening,
I currently have an application where an ESP-32 is configured as a TCP/IP server, allowing multiple clients connections. The server is the only one sending data. Therefore, all the clients are only receiving information and not sending anything to the server.
When a client connects, it starts to receive data. Everytime the server sends data, it receives the OK and SEND OK replies. However, if we place the client out of range from the server, the server freezes waiting the SEND OK or SEND FAIL reply. At this point, I am not able to send any data to the esp-32. It takes about 3 minutes for the esp-32 server to understand that the client is out of range, to close the connection and to provide the SEND FAIL reply. Only after this the esp-32 comes back to accept the commands.
Since I am dealing with multiple clients, I must be able to continue sending data to the clients that are in range eventhough there is a client that lost range. I cannot wait 3 minutes without sending data to any client in order to regain control of the esp-32 server.
Any thoughts in how to solve this issue?
Thank you,
Rodrigo
ESP-32 TCP/IP server freezes when trying to send data to client out of range
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: ESP-32 TCP/IP server freezes when trying to send data to client out of range
I assume you use standard sockets to send this? The way to go would be either to use select() to wait for the socket to be writable, or to make your sockets non-blocking.
Re: ESP-32 TCP/IP server freezes when trying to send data to client out of range
I am using the ESP-32 AT command set list to perform all the configurations. In order to send data i am using the AT+CIPSEND command. How can i configure a non-blocking socket using the AT command set?
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: ESP-32 TCP/IP server freezes when trying to send data to client out of range
Ah, never mind then, I have no idea about the AT command set. I'll move your post to the forum that discusses it, perhaps someone else does.
Re: ESP-32 TCP/IP server freezes when trying to send data to client out of range
Hi, maybe you can set the <so_sndtimeo> parameter of the AT+CIPTCPOPT (https://docs.espressif.com/projects/esp ... et-options) command, when the device is out of range, it will return SEND FAIL and close the connection at the time you set.
Re: ESP-32 TCP/IP server freezes when trying to send data to client out of range
Hi ESP_SUN,
I have tried what you suggested. After setting the <so_sndtimeo> to 500 ms, I received the following answer from the module:
+CIPTCPOPT:0,-1,0,500
+CIPTCPOPT:1,-1,0,500
+CIPTCPOPT:2,-1,0,500
+CIPTCPOPT:3,-1,0,500
+CIPTCPOPT:4,-1,0,500
OK
However, after performing the same tests, the so_sndtimeo setted is not respected. After the client goes out of range, the server takes about 90 seconds to close the connection and to allow me to talk to it again. After several trials, this timeout of 90 s is always respected after client is out of range.
Do you know which time constant is setted to 90 s in the source code? Which command AT should I use in order to change this value?
Thank you,
Rodrigo
I have tried what you suggested. After setting the <so_sndtimeo> to 500 ms, I received the following answer from the module:
+CIPTCPOPT:0,-1,0,500
+CIPTCPOPT:1,-1,0,500
+CIPTCPOPT:2,-1,0,500
+CIPTCPOPT:3,-1,0,500
+CIPTCPOPT:4,-1,0,500
OK
However, after performing the same tests, the so_sndtimeo setted is not respected. After the client goes out of range, the server takes about 90 seconds to close the connection and to allow me to talk to it again. After several trials, this timeout of 90 s is always respected after client is out of range.
Do you know which time constant is setted to 90 s in the source code? Which command AT should I use in order to change this value?
Thank you,
Rodrigo
Re: ESP-32 TCP/IP server freezes when trying to send data to client out of range
Hi Rodrigo,
1. Yes, I reproduced your problem too. The AT+CIPTCPOPT command does not currently work with a device acting as a server. It is being improved internally. If there is any progress, I will let you know as soon as possible.
2. 90 seconds is because it takes time to retransmit data at the protocol layer, which is a normal phenomenon.
Thank you very much for your question
sun
1. Yes, I reproduced your problem too. The AT+CIPTCPOPT command does not currently work with a device acting as a server. It is being improved internally. If there is any progress, I will let you know as soon as possible.
2. 90 seconds is because it takes time to retransmit data at the protocol layer, which is a normal phenomenon.
Thank you very much for your question
sun
Re: ESP-32 TCP/IP server freezes when trying to send data to client out of range
Hi Sun,
I understand that your protocol probably have a number of retries to be performed if an ACK is not received from the Client. However, 90 s is a little high.
That would be excellent if the maximum number of retries / retry times could be configured.
As far as I understood, this cannot be configure using the AT commands within a TCP server, correct? If I code into the module directly, without using the AT commands, would I be able to change this configuration?
Sorry for bothering asking, however, since I have a real-time application, I cannot stop sending data to the other clients on the network if only one client is out of range.
Thank you,
Rodrigo
I understand that your protocol probably have a number of retries to be performed if an ACK is not received from the Client. However, 90 s is a little high.
That would be excellent if the maximum number of retries / retry times could be configured.
As far as I understood, this cannot be configure using the AT commands within a TCP server, correct? If I code into the module directly, without using the AT commands, would I be able to change this configuration?
Sorry for bothering asking, however, since I have a real-time application, I cannot stop sending data to the other clients on the network if only one client is out of range.
Thank you,
Rodrigo
Re: ESP-32 TCP/IP server freezes when trying to send data to client out of range
Hi,
Maybe you can try changing the number of retransmissions in menuconfig to reduce this time.
Maybe you can try changing the number of retransmissions in menuconfig to reduce this time.
Who is online
Users browsing this forum: No registered users and 3 guests