I'm having an issue with TCP RST instead of FIN.
Posted: Sat May 27, 2017 8:00 am
I've put together a small web server to act as a control and diagnostics panel on a device controlled by an STM32F407 microcontroller.
I am using the current latest AT command firmware image (2.1.0).
My controller sets up an ESP-01 module as an access point that can take 1 connection with the following commands:
(there may be some transcription errors since this is being pulled out of a C program)
I am using a selection of browsers, phones, and computers to connect to my controller; Mac, iPhone, iPod, Safari, and Chrome, and I'm having issues with a couple of the combinations not receiving the html stream completely.
The web page that I am serving uses the tag:
"<meta http-equiv="refresh" content="5">"
Which causes the web page to be re-requested every 5 seconds. The screen will render properly, every 5 seconds for days, on an iPod Touch using Safari and a Mac using Safari. But on an iPhone 4 with Safari or Mac with Chrome, it will render properly a handful of times and then give a blank screen complaining that the connection was lost.
On the controller to ESP-01 side, the serial conversation looks very clean. No busy errors. I use an oscilloscope with serial decode to show what is being transferred and the timing, and there are no serial issues. The conversation looks like:
I ran Wireshark to take a look at what is happening and the normal conversation looks like:
But when my web pages do not render properly, the conversation looks like:
Talking with a friend who has worked at large networking companies that sound like Risco, he mentioned that a RST can be sent out in reply to data received against a closed connection. That could mean that the ACK for data segment 2 could be received after the connection is closed.
So, I put in a 100mS delay between receiving the "/r/nSEND OK/r/n" message and sending the "AT+CIPCLOSE=0/r/n" command. The problem is reduced a small amount, so I increased the timing to 150mS, but the problem persists.
Instead of waiting for the FIN packet from the PC, the module is sending an RST packet. I hope this makes sense, the information is difficult to describe.
Can anybody shed any light on this?
Thanks,
Andrei Chichak
I am using the current latest AT command firmware image (2.1.0).
My controller sets up an ESP-01 module as an access point that can take 1 connection with the following commands:
(there may be some transcription errors since this is being pulled out of a C program)
Code: Select all
AT\r\n
ATE0\r\n
AT+RFPOWER=80\r\n
AT+CWSAP_CUR="CompanyName0000","12345678",5,3,1,0\r\n
AT+CWMODE_CUR=2\r\n
AT+CIPMUX=1\r\n
AT+CIPSERVER=1,80\r\n
I am using a selection of browsers, phones, and computers to connect to my controller; Mac, iPhone, iPod, Safari, and Chrome, and I'm having issues with a couple of the combinations not receiving the html stream completely.
The web page that I am serving uses the tag:
"<meta http-equiv="refresh" content="5">"
Which causes the web page to be re-requested every 5 seconds. The screen will render properly, every 5 seconds for days, on an iPod Touch using Safari and a Mac using Safari. But on an iPhone 4 with Safari or Mac with Chrome, it will render properly a handful of times and then give a blank screen complaining that the connection was lost.
On the controller to ESP-01 side, the serial conversation looks very clean. No busy errors. I use an oscilloscope with serial decode to show what is being transferred and the timing, and there are no serial issues. The conversation looks like:
Code: Select all
0,CONNECT\r\n
\r\n+IPD,0,415:GET /diag.html HTTP/1.1 Host: 192.168.4.1 ... and a lot of parameters\r\n\r\n
AT+CIPSEND=0,775\r\n
\r\nOK\r\n>
HTTP/1.0 200 OK Accept:text/html ... and a lot more display code ... \r\n
\r\nRecv 775 bytes\r\n
\r\nSEND OK\r\n
AT+CIPCLOSE=0\r\n
0,CLOSED\r\n\r\nOK\r\n
I ran Wireshark to take a look at what is happening and the normal conversation looks like:
Code: Select all
SYN
SYN,ACK
ACK
data (GET /diag.html)
ACK
data segment 1
ACK
data segment 2
ACK
FIN, ACK
ACK
But when my web pages do not render properly, the conversation looks like:
Code: Select all
SYN
SYN,ACK
ACK
data (GET /diag.html)
ACK
data segment 1
ACK
data segment 2
ACK
RST,ACK
Talking with a friend who has worked at large networking companies that sound like Risco, he mentioned that a RST can be sent out in reply to data received against a closed connection. That could mean that the ACK for data segment 2 could be received after the connection is closed.
So, I put in a 100mS delay between receiving the "/r/nSEND OK/r/n" message and sending the "AT+CIPCLOSE=0/r/n" command. The problem is reduced a small amount, so I increased the timing to 150mS, but the problem persists.
Instead of waiting for the FIN packet from the PC, the module is sending an RST packet. I hope this makes sense, the information is difficult to describe.
Can anybody shed any light on this?
Thanks,
Andrei Chichak