- Joined
- Jul 4, 2009
- Messages
- 16,487
- Helped
- 5,157
- Reputation
- 10,347
- Reaction score
- 5,207
- Trophy points
- 1,393
- Location
- Aberdyfi, West Wales, UK
- Activity points
- 139,487
Here's an interesting problem to which I'm open to ideas:
Scenario - an ESP8266 module is plugged into a control system via a serial link. The link is a very basic TX/RX connection via a MAX3232, no handshaking is used. The module runs as a Telnet interface and is linked to a WiFi router nearby. The WiFi link works fine and is reliable. The router 'port forwards' the module IP address (fixed) to a public external address and port number (also fixed), this allows external access through the Internet to the router and then the ESP8266 module. All works perfectly.
Problem - when accessed from a fixed location, wherever it is, the connection is reliable even after many days. However, when accessed from a mobile device, for example a 3G/4G phone, it sometimes permanently locks up with the mobile end receiving a "closed by foreign host" message. My investigation shows that what happens is when the mobile device either loses signal or moves to a different cell, it gets a new IP address from the Telco but the ESP8266 still has the original Telnet connection running and only one connection at a time is allowed. So the connection does reach the ESP8266 but it sees a second user with the first one still logged in and refuses the session.
I could allow more than one user at a time to connect but that would only delay the problem. The module still sees the local router all the time so I can't use a loss of WiFi connection to force a reset. Unfortunately, the ESP8266 Telnet code resets the internal watchdog inside it's library code so I can't rely on it to force a hardware reset after a period of inactivity. Typical incoming data to the ESP8266 is only a few command bytes and the outgoing data can be anything from one byte to about 32K bytes.
Anyone have any ideas?
The best I can come up with is an external timer hooked to the reset pin and reset by data leaving the ESP8266 TX pin. The idea being that no incoming data from the internet means nothing should come out of the TX pin so the connection might be lost. The drawback to this is it would put the module into a periodic reset loop when not being used with a few seconds of dead time each pass of the loop while it re-initializes and logs back into the router.
Brian.
Scenario - an ESP8266 module is plugged into a control system via a serial link. The link is a very basic TX/RX connection via a MAX3232, no handshaking is used. The module runs as a Telnet interface and is linked to a WiFi router nearby. The WiFi link works fine and is reliable. The router 'port forwards' the module IP address (fixed) to a public external address and port number (also fixed), this allows external access through the Internet to the router and then the ESP8266 module. All works perfectly.
Problem - when accessed from a fixed location, wherever it is, the connection is reliable even after many days. However, when accessed from a mobile device, for example a 3G/4G phone, it sometimes permanently locks up with the mobile end receiving a "closed by foreign host" message. My investigation shows that what happens is when the mobile device either loses signal or moves to a different cell, it gets a new IP address from the Telco but the ESP8266 still has the original Telnet connection running and only one connection at a time is allowed. So the connection does reach the ESP8266 but it sees a second user with the first one still logged in and refuses the session.
I could allow more than one user at a time to connect but that would only delay the problem. The module still sees the local router all the time so I can't use a loss of WiFi connection to force a reset. Unfortunately, the ESP8266 Telnet code resets the internal watchdog inside it's library code so I can't rely on it to force a hardware reset after a period of inactivity. Typical incoming data to the ESP8266 is only a few command bytes and the outgoing data can be anything from one byte to about 32K bytes.
Anyone have any ideas?
The best I can come up with is an external timer hooked to the reset pin and reset by data leaving the ESP8266 TX pin. The idea being that no incoming data from the internet means nothing should come out of the TX pin so the connection might be lost. The drawback to this is it would put the module into a periodic reset loop when not being used with a few seconds of dead time each pass of the loop while it re-initializes and logs back into the router.
Brian.