Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AT+CIPCLOSE resets ESP8266 (after successful HTTP GET) #2

Closed
damellis opened this issue Feb 8, 2015 · 13 comments
Closed

AT+CIPCLOSE resets ESP8266 (after successful HTTP GET) #2

damellis opened this issue Feb 8, 2015 · 13 comments

Comments

@damellis
Copy link
Contributor

@damellis damellis commented Feb 8, 2015

This is an issue with the ESP8266 module / firmware, not the Adafruit library but I'm describing it here because it may affect people trying to use the library.

The problem I'm seeing is that, after successfully retrieving an HTTP page, sending the AT+CIPCLOSE command to close the TCP connection seems to reset the module. (See full log below.) Maybe this is because the ESP8266 is confused by the fact that the other end has already dropped the connection? (An AT+CIPSTATUS just before the AT+CIPCLOSE gives the status as connected.)

After the reset, the module still appears to be connected to the same wifi network and working (able to do another HTTP GET), so it might be possible to work around this. Still, it seems to complicate the use of the module if it resets unexpectedly (and generates unexpected data in the form of the boot message).

Any one else seen this? Ideas for how to cleanly close the connection without reseting the module?

AT+RST


OK
�ö,����ÿ¨¬�
¡åúÈ@JSè�àè
[Vendor:www.ai-thinker.com Version:0.9.2.4]

ready
AT+GMR

0018000902-AI03

OK
AT+CWMODE=1

no change
AT+CWJAP="Mellis",""


OK
AT+CIPMUX=0


OK
AT+CIFSR

192.168.2.5

OK
AT+CIPSTART="TCP","www.adafruit.com",80


OK
Linked
AT+CIPSEND=61

> GET /testwifi/index.html HTTP/1.1
Host: www.adafruit.com


SEND OK

+IPD,536:HTTP/1.1 200 OK
Date: Sun, 08 Feb 2015 22:31:58 GMT
Server: Apache
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Accept-Encoding, Authorization, Referer, User-Agent
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Credentials: true
Access-Control-Max-Age: 1728000
Last-Modified: Thu, 27 Jun 2013 14:13:27 GMT
Accept-Ranges: bytes
Content-Length: 74
Vary: Accept-Encoding
Content-Type: text/html

This is a test of the CC3000 module!
If you can read this, its working :)

OK
AT+CIPSTATUS

STATUS:3
+CIPSTATUS:0,"TCP","207.58.139.247",80,0

OK
AT+CIPCLOSE

@fÌ8¤ÿ���ÿ¨¬�9¡åúÈ@J?É��è
[Vendor:www.ai-thinker.com Version:0.9.2.4]

ready
@aremes

This comment has been minimized.

Copy link

@aremes aremes commented Apr 12, 2015

Hi!

A little late, maybe but still:

Ran into this just now. Not sure if this fully works (debugging the ESP is a pain). Make sure you send a "Connection: keep-alive" header along with your request. If not, the remote end might close the connection which seems to upset the ESP because it seems to want to be in charge of managing that. you might then get a response where the server explicitly tells you it wants to close ("Connection: close" in response header) Calling AT+CIPCLOSE then seems to work without resetting the ESP or blocking subsequent tcp-connections. If you still get resets, try disabling the watchdog timer ("AT+CSYSWDTDISABLE"). Finally, check your power supply. you're gonna want to be able to supply at least 500mA @3.3V.

Best of luck!

update: I still get the ESP boot message every so often (completely random now, happens a lot less though..) but the wifi connection remains active.. it might be something else, may not even be a reset but a "feature"??

@kariofillis

This comment has been minimized.

Copy link

@kariofillis kariofillis commented Apr 23, 2015

I have a similar issue, but it resets the module when i send the AT+CIPSTART.... Any ideas??? :s I am on the same version (0018000902-AI03).

Edit: I do have it on sufficient power supply...

@aremes

This comment has been minimized.

Copy link

@aremes aremes commented Apr 23, 2015

i strongly suggest switching over to the nodemcu firmware. save yourselves the headache of dealing with the awkward AT commandset. + no more unexpected resets, busy signals, etc.. ! :)

@damellis

This comment has been minimized.

Copy link
Contributor Author

@damellis damellis commented Apr 23, 2015

@aremes is there a serial protocol on top of the nodemcu firmware? That would be a nice option for those of us that prefer an external microcontroller (e.g. so we can write code in Arduino).

@aremes

This comment has been minimized.

Copy link

@aremes aremes commented Apr 26, 2015

you can senf lua commands over UART to the ESP. Its what i'm doing. so you can put common configutation in a startup script, then execute specific commands using your external controller.

@timr49

This comment has been minimized.

Copy link

@timr49 timr49 commented May 4, 2015

I get the "[Vendor:www.ai-thinker.com Version:0.9.2.4]" reset text sometimes but not always when using the module as a HTTP server (rather than client as in examples above). After this occurs, the it no longer accepts connections.

Still investigating, current hypothesis is that it is related to volume of data sent.

This post is really just a "yes" answer to OP's question "Any one else seen this?"

@sabag

This comment has been minimized.

Copy link

@sabag sabag commented May 13, 2015

i also had this problem (reset after both CIPCLOSE and CIPSTART), and the "Connection: keep-alive" helped me.

@macedolfm

This comment has been minimized.

Copy link

@macedolfm macedolfm commented Jul 6, 2015

Hi, Had same issues, stopped using AT+CIPCLOSE and all problems went away since I only connecto to the same website every 5 minutes. Invetigated further, calling AT+CIPSTATUS twice before calling AT+CIPCLOSE and only AT+CIPCLOSE when getting a "STATUS:3" also fixed the problem...so far.

@sdugator

This comment has been minimized.

Copy link

@sdugator sdugator commented Jul 12, 2015

Hi, got the same AT+CIPCLOSE issue and tried tricks given above, but would still get errors. I found that closing the server will actually close the connection. It can be reopened safely afterwards.
My code looks like
AT+CWMODE=3
AT+CIPMODE=0
AT+CWJAP="wifi","pass"
AT+CIPMUX=1
while(1) {
AT+CIPSERVER=1,port
wait some incomming data
AT+CIPSEND=id,len // reply with some data
data
AT+CIPSERVER=0
}

My module firmware replies as follow to AT+GMR:
AT version:0.21.0.0
SDK version:0.9.5

@macedolfm

This comment has been minimized.

Copy link

@macedolfm macedolfm commented Jul 13, 2015

Hi, all my attempts did not solve the RST problem for good. I have a MEGA posting every 15 seconds to a web server, it is running 24/7 for the last 4 days, so far. Despite implementing most of the procedures & tricks describe above I still get an unexpected RST every 3 or 4 hours. Solved the problem the dumb way: scanning every string returned from the ESP8266 and looking for the word "ready", if found, I assume an unexpected RST just happened and re-restart the module setup from scratch including a new AT+RST, etc.. (just soldered two HW pins for a hard RST and Power Down the module, but did not test them yet), the ESP8266 takes 6 seconds or less to be back to work and the sketch is running rock solid despite the RST mess...hope the 1.0 Firmware fix this..

@welcomeRESPONSE

This comment has been minimized.

Copy link

@welcomeRESPONSE welcomeRESPONSE commented Sep 30, 2015

Hi all.

I am a little bit stuck and I could REALLY use some help. So my friend and I are trying to send data through a server to a database (ESP8266 + Arduino, Apache Server and Mysql Database). When we send data, it says “send ok” and after that it says connection timeout. On apache it says 408 error. A few times we got 200 4961 (this is what we want) but that only happens when we send GET /HTTP/1.1 and when we send to GET/index.php?img=pngPlugIn HTTP/1.1. We try to send GET /pm/add_message.php?pmu=RAL005-07001-FL02-0030-2L Host:192.168……. but we get 408 320. Any suggestions? Do you know what we might be doing wrong?

@sabag

This comment has been minimized.

Copy link

@sabag sabag commented Sep 30, 2015

hi again,
since 5 months ago when i had so many problems working with the esp8266 with its AT firmware, a lot has developed in this area, and the best of it is that you can now write a sketch for the esp in the arduino IDE the way we know and got used to, then the IDE will flash the esp. in this way i was able to continue with my project successfully by communicating the arduino with the esp using I2C easily.
i recommend doing so also

@tdicola

This comment has been minimized.

Copy link
Contributor

@tdicola tdicola commented Oct 6, 2015

Yep definitely check out the ESP8266 Arduino project for running code natively on the ESP8266 instead of using its AT command firmware: https://github.com/esp8266/Arduino Once you get the IDE setup to talk to the ESP8266 and program it you'll find it's a lot easier to use than the AT commands. The ESP8266 Arduino library is also under active development so you'll likely find it has more recent fixes, etc. vs. the AT command firmware from Espressif.

For the 408 timeout issue though be careful to check that you're terminating the HTTP request the right way. For example make sure you aren't telling the server that you're sending a large amount of content (like a Content-Length header with a big value) and then failing to send all the data--that would likely make Apache wait for more data and eventually timeout with a 408 error when it never receives the data it expects.

I'll close this issue for now since issues with the AT command firmware are probably better raised on Espressif's forums (since they maintain the AT command firmware): http://bbs.espressif.com/ Thanks!

@tdicola tdicola closed this Oct 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.