My favorites | Sign in
Project Home Downloads Wiki Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 1024: TCP connections die after few seconds of inactivity
11 people starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  dmel...@gmail.com


Sign in to add a comment
 
Reported by marco.li...@liarco.net, Aug 31, 2012
Hardware:
 - Arduino Leonardo
 - WiFi Shield

Software:
 - Arduino IDE 1.0.1
 - Mac OSX 10.7 / Ubuntu 12.04

Libraries:
 - WiFi Libraries (downloaded from arduino.cc)

What steps will reproduce the problem?
1. Code a sketch to open a TCP connection with a simple TCP server (I tried with a Node.js HelloWorld as server)
2. Sending and receiving messages works fine, so wait few seconds and the connection will be closed by the Arduino with a "reset" packet as the last packet sent from the board.
3. Now you can't send/receive anything more and the server is not correctly notified about the connection status until it tries to read/write.

What is the expected output? What do you see instead?
I expected the connection to be kept open until it was closed properly by the server/client. No other client (except for Arduino) seems to drop the connection in this way.

I'm gonna attach a wireshark log about the traffic produced by my TCP server and the board.

Kind Regards.
Marco Lipparini
ArduinoWifi_wireshark_capture
1007 bytes   Download
Sep 5, 2012
#1 the.baum...@gmail.com
The wireshark trace shows the disconnect happens 18 seconds after the last activity. 
Sep 5, 2012
#2 marco.li...@liarco.net
I see... do you mean that can this be considered a normal behavior?
Sep 5, 2012
#3 the.baum...@gmail.com
No. I agree with you that this is a bug. I see the same exact behavior with the Arduino WiFi shield in my testing. My tests with other devices like the Arduino Ethernet shield and Sparkfun WiFly shield do not exhibit this behavior.  They will remain connected. I was basically doing a +1 (a me too) but with information that is present in your capture and my capture.  I figured it may be useful to point out in text of this issue that this timer (wherever it is) appears to be 18 seconds.
Sep 5, 2012
#4 marco.li...@liarco.net
I'm sorry, I misunderstood your message!

Thanks for your reply, I hope this bug will be fixed soon because it's really annoying! :(

Suggestion: now I made my Arduino sending an "heartbeat" packet every "FIXED_TIME" in order to avoid the disconnection... I hope that this can help other beginners out there while we wait for a real fix!
Sep 6, 2012
#5 thebluel...@gmail.com
I also have the same problem and had to implement the same heart beat solution as a work around. The Arduino WiFi is an expensive shield and this kind of major bug is inacceptable in my opinion. Hopefully a fix is coming soon. 
Oct 3, 2012
#6 dariovit...@gmail.com
Hello everyone, i want report that i have the same problem with WiFi Shield R3 connected to the Arduino Uno R3 like Server using WiFi libraries (arduino.cc). Connection die after few seconds and it not occurs with Ethernet Shield (Arduino) and WiFly Shield (Sparkfun) i tested with library example code.
I hope that this bug will be soon fixed.
Thanks a lot.
Oct 20, 2012
#8 marka65...@googlemail.com
Hi,
I am using WiFi Shield R3 connected to the Arduino Uno R3 like Server using WiFi libraries (arduino.cc). Connection dies after a few seconds. 
Oct 20, 2012
#10 k...@vmfarms.com
I'm experiencing the same issue. This is most definitely a bug, otherwise it would be a *configurable* feature. I stumbled upon the same keepalive solution others did on my own, however, I'd like to get a proper fix.
Oct 20, 2012
#11 k...@vmfarms.com
Furthermore, it seems like when the server initiates the disconnect due to timeout (without keepalive), I am no longer able to reconnect with the client. The port is open, but the client can never be served.

If the client initiates the disconnect (EOF), you can reconnect without issue.
Oct 20, 2012
#12 k...@vmfarms.com
It seems as though if you call a server.status() after you've been disconnected, a 0 is returned, whereas 1 indicates it is healthy. There is no functionality to tear down a server and restart it from what I can tell from the firmware and libraries.
Oct 23, 2012
#13 the.baum...@gmail.com
The lwip (Light Weight IP)  tcp_poll function is being used by the firmware to define callback functions atcp_poll and atcp_poll_conn.

These are both checked roughly once every two seconds.

There is a value called tcp_poll_retries that is checked in these functions.  

The TCP connection is aborted when tcp_poll_retries is > 4 (so 5) in atcp_poll or when tcp_poll_retries is > 8 (so 9) in atcp_poll_conn.

The tcp_poll_retries value is incremented by 1 every two seconds no data is sent.

The tcp_poll_retries value only appears to get reset to 0 when data is successfully sent [tcp_data_sent].  

So, this appears to be an intentional mechanism used to kill the TCP connection when no data has been sent for 10 seconds or 18 seconds respectively.

The firmware and WiFi shield library should be modified to allow the user to configure or disable this timer.

I have tried to import the wifiHD project into Eclipse so I could look at making the change on the firmware side.

I have the AVR-Eclipse plugin installed.

However, like others have mentioned I am not able to successfully import this project into Eclipse.

Arduino Developers please update the github files (or provide additional instructions) so that the user base can start to make changes.

Oct 23, 2012
#14 k...@vmfarms.com
Yes please. You can refer to http://arduino.cc/forum/index.php/topic,128424.0.html for a discussion on this issue and others with the wifi shield. Your comments would be appreciated there.
Oct 24, 2012
#15 k...@vmfarms.com
The developers released a patched firmware to github this morning. I've flashed my board and it has taken care of my issues. I've posted an update in the arduino.cc forum topic above. Give it a shot.
Dec 15, 2012
#16 Clck...@gmail.com
This issue has only been fixed for TCP servers. The problem still occurs when you create a TCP client, connect to any server, and leave it idle for a few seconds. The TCP client will disconnect. 

You can (and as a stopgap I am ) send heartbeat packets to keep it alive, but I'd prefer not to because I'm concerned about squeezing every drop of battery life out of this thing!
Sign in to add a comment

Powered by Google Project Hosting