Cannot connect to ESP8266 after a while

akouz
Posts: 27
Joined: Tue May 10, 2016 1:10 pm

Cannot connect to ESP8266 after a while

Postby akouz » Mon Aug 15, 2016 2:07 pm

Hi,

After power-up/restart I initialise ESP8266 as follows:

AT+CWMODE_CUR=3 - set mode "station+softAP"
OK
AT+CWJAP_CUR="MyNetwork","xxxxxxxx" - connect to local network
WIFI CONNECTED
WIFI GOT IP
OK
AT+CIPMUX=1 - multi-connect mode
OK
AT+CIPSERVER=1,1300 - start TCP server, port 1300
OK

After that ESP8266 works quite well. I can broadcast UDP messages, or I can serve TCP requests coming from softAP network or from local network. It can be HTTP requests from a browser, or binary messages from custom software. I can access it from my mobile phone, from my desktop or from laptop, no problems.

But it does not work for long. After a few hours ESP8266 may continue to serve TCP request from one computer and refuses to make TCP connectoins to other computers. It continues to send UDP messages, it may serve HTTP requests in softAP network, but in the local network it talks to one and only one computer, refusing to make connection to any other computer. Say, on my desktop I can access ESP8266 TCP server via browser or via custom software. But I cannot access it from other computers in the local network. Other computers just wait for connection for long time and then finish by time-out. ESP8266 does not show any AT commands or echo when I try to connect from other computers, but it shows expected traffic when I connect my desktop computer.

I tried to reset TCP server:
AT+CIPSERVER=0
AT+CIPSERVER=1,1300
That does not help.

If I restart module by AT+RST and then re-initialise it, everything works again. For a while.

What is wrong?

pratik

Re: Cannot connect to ESP8266 after a while

Postby pratik » Mon Aug 15, 2016 7:26 pm

Hello,

Could you please use AT+GMR and inform about the SDK/firmware version? Also, have you added custom AT commands to the firmware?

When you face this problem that you described, please use AT+RST and then see if the problem is resolved or not. If resolved, then probably a software issue. Otherwise may be hardware/network issue.

akouz
Posts: 27
Joined: Tue May 10, 2016 1:10 pm

Re: Cannot connect to ESP8266 after a while

Postby akouz » Tue Aug 16, 2016 8:00 am

AT version:0.60.0.0(Jan 29 2016 15:10:17)
SDK version:1.5.2(80914727)
There is one custom AT command there, AT+RADC. It reads ADC.

As I said above, AT+RST command solves the problem, but it solves it for a while only. After few hours the same problem appears again.

We are trying to reproduce the problem in shorter time. We run test programs on PC. One of the test programs does a rather simple job:
- Open TCP connection
- Send 3 bytes of binary data
- Close TCP connection.
Test program does it at maximum speed using 30 threads. Apparently PC is much faster than ESP8266, and WiFi is much faster than serial port at 115 kbps. Thus, I would expect that the operations speed should be defined by ESP8266 reactions. If ESP requires some time to receive data and send them via UART, it may wait before opening a new TCP connection. Measured throughput is about 600 bytes per second, thus, ESP processes about 200 transactions per second

The following is a sample of ESP8266 output seen by serial monitor:

0,CONNECT
+IPD,0,3:<...>0,CLOSED
0,CONNECT
1,CONNECT
+IPD,1,3:<...>1,CLOSED
+IPD,0,3:<...>0,CLOSED

... etc. After a few seconds ESP8266 hangs. The last output from ESP8266 seen by serial monitor is as follows:

+IPD,2,3:<...>3,CONNECT
4,CONNECT
0,CLOSED
0,CONNECT
1,CLOSED
2,CLOSED
1,CONNECT
2,CONNECT
0,CONNECT FAIL
1,CONNECT FAIL
2,CONNECT FAIL
3,CONNECT FAIL
4,CONNECT FAIL

After that ESP8266 output is frozen. It does not react to any AT commands, including AT+RST.

It looks like a seriuos problem, is not it? Anyone can crash ESP8266 via WiFi just by running a similar program on PC.

pratik

Re: Cannot connect to ESP8266 after a while

Postby pratik » Wed Aug 17, 2016 10:12 am

Hello,

If you are reading the ADC anywhere between these connection-disconnection cycles, please substitute that code and use a dummy value. The ADC is closely linked with internal RF circuitry and may cause issues at times if not used properly.
The second option is to simply generate the firmware without any modification to it (no custom AT commands at all) and then try to see if behaves this way again.

Meanwhile, I will have this checked for a memory leak issue (you can also print free system memory every time you connect/disconnect), if it decreases, you probably have a memory bug somewhere!

akouz
Posts: 27
Joined: Tue May 10, 2016 1:10 pm

Re: Cannot connect to ESP8266 after a while

Postby akouz » Wed Aug 17, 2016 10:57 am

Hi Pratik,

Thanks.

Sorry, I do not use the new AT+RADC command at all.

you can also print free system memory every time you connect/disconnect


Please explain how can I do that. I do not know how to print free ESP8266 system memory using AT commands.

Regards
Alex

akouz
Posts: 27
Joined: Tue May 10, 2016 1:10 pm

Re: Cannot connect to ESP8266 after a while

Postby akouz » Tue Aug 23, 2016 3:11 pm

While waiting for modules with bigger flash where I can fit the latest AT commands, I keep testing the code with AT rev 0.60. Sometimes the following messages appear at ESP8266 output without any visible reason:

WIFI DISCONNECT
WIFI CONNECTED
WIFI GOT IP

After that connection to network is lost, and softAP does not respond to requests too. It just refuse to connect.


Why could it be?

pratik

Re: Cannot connect to ESP8266 after a while

Postby pratik » Tue Aug 23, 2016 3:58 pm

The reason for these messages is that the router has probably disconnected from the ESP station. This could be because of spikes in power supply for the ESP8266. Please make sure you provide a high quality power supply and decouple it properly.
Also, please use the latest firmware. We fix MANY issues with every subsequent update. This might be one of those. v.1.5.x received many patches because of small issues. Therefore, I would recommend upgrading to SDK v.2.0.0 if the problem cannot be resolved.

akouz
Posts: 27
Joined: Tue May 10, 2016 1:10 pm

Re: Cannot connect to ESP8266 after a while

Postby akouz » Fri Aug 26, 2016 6:44 am

I downloaded the latest SDK 2.0 and programmed the "noobot" AT code for 512K.

Good news: this version does not crash on the "connect - send 3 bytes - disconnect" sequence.

Bad news: this version still refuses to make TCP connections to some computers after about one hour, at random.

ESP8266 is in station+softAP mode, multiple connection mode, it runs TCP server, as described above. In our application we supposed to connect to our device with ESP8266 from any computer in network. Our device runs HTTP server. A browser from any computer in the local network can establish connection to HTTP server and request HTML pages.


After power-up or reset everything works OK.

After about one hour some computers cannot connect to ESP8266. After sending request to ESP8266 their browsers waits and then exit by time-out. ESP8266 UART output does not indicate that connection is established, it is silent, there is no traffic.

The same time other computers still can connect to ESP8266. Its UART output shows messages such as "0,CONNECT" and then incoming HTTP request from the browser.
Last edited by akouz on Fri Aug 26, 2016 7:04 am, edited 1 time in total.

pratik

Re: Cannot connect to ESP8266 after a while

Postby pratik » Fri Sep 02, 2016 10:01 am

I will forward this to an engineer for review, you should get a response soon if they are able to reproduce the problem.
Until then, switching to another AT firmware version is recommended, if this is indeed a firmware issue.

akouz
Posts: 27
Joined: Tue May 10, 2016 1:10 pm

Re: Cannot connect to ESP8266 after a while

Postby akouz » Sun Sep 04, 2016 1:19 pm

The problem could be caused by our access point. We test it with other access points. In some cases it works OK for long time.

Who is online

Users browsing this forum: No registered users and 126 guests