Tcp server disconnecting if idle for sometime

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

I want to display the data from uart to the webpage(client) via tcp connection. once data has been received wifi module(server) will transmit data to the webpage(client).

If no data has been received for more than 2 minutes(i.e. wifi module is idle) tcp serever(wifi module) is getting disconnected and webpage is showing could not connect to server.

What i have done is iam receiving the data from uart (i don't know the size of the data iam receiving so i have given that wiced_uart_receive_bytes in while condition which receives 1 character till end of string is reached, once it reaches the end of the string iam breaking that loop)after that iam checking for tcp accept and iam trying to send the data........y it is happening ??? how can i make the server not to get disconnected after sometime....please help me...

And how can I change the ThreadX/NetX_Duo to lwIP.....

Thank you!!!

0 Likes
9 Replies
GauravS_31
Moderator
Moderator
Moderator
10 questions asked 250 solutions authored 250 sign-ins

Are you getting this problem in the current version of Wiced SDK that is Wiced Studio 4.0.1? Which platform are you currently using?

0 Likes
JeGu_2199941
Level 5
Level 5
25 likes received 10 likes received 10 likes given

This looks similar to unexpected MQTT disconnect event issue I face. Both from TCP disconnected event by network stack...
In my case, same symptom is seen from 3.4.0 to 4.0.1

0 Likes
Anonymous
Not applicable

Thank you for your reply....

I am using wiced sdk 2.4.0........

What you did to resolve your problem...how can I make server not to get disconnected after 2 minutes....

Please reply me!!!!!!!

0 Likes
GauravS_31
Moderator
Moderator
Moderator
10 questions asked 250 solutions authored 250 sign-ins

Can you enable TCP keepalive flag in your application and check if it solves your problem? Regarding your question on LwIP, you can modify the build statement to include the relevant RTOS. For instance, you can write snip.scan-FreeRTOS-LwIP-BCM943907AEVAL1F download run.

0 Likes

grsr wrote:

Can you enable TCP keepalive flag in your application and check if it solves your problem?

Kaviyaa was testing with NetX/NetX_Duo.

Are you sure NetX/NetX_Duo support tcp keepalive?

AFAICT, wiced_tcp_enable_keepalive() returns WICED_TCPIP_UNSUPPORTED for NetX/NetX_Duo build.

From the description, he is testing with ThreadX/NetX_Duo. I tested the snip tcp_server in Wiced Studio 4.0.1 and the wiced_tcp_enable_keepalive() returned WICED_SUCCESS when I tested with ThreadX/NetX_Duo, so yes ThreadX/NetX_Duo supports tcp keepalive.

0 Likes

I double check the code in 4.0.1:

wiced_tcp_enable_keepalive() returns WICED_TCPIP_UNSUPPORTED for NetX, but reutrns SUCCES for NetX_Duo.

However, such issue should not happen at all when tcp keep alive is disabled.

How enable tcp keepalive can fix the problem?

It looks like wiced_tcp_enable_keepalive() is nothing to do with this problem.

Anonymous
Not applicable

Thank you for all of you for your kind response!!!

If wicked_tcp_enable_keepalive has nothing to do with it...then what might be the problem why my server is getting disconnected after 2 minutes...

Client will sent me start ...I will wait for data to be received from uart then I will accept the client's request and will transmit the data to client... this continues.... if client send me some request and I am waiting for uart data for more than 2 minutes server is getting disconnected... why it is happening.... what is the reason for this disconnection....

Please tell me why it is happening??

Thank you...

0 Likes

Why you not try to using wireshark to capture your TCP packets on your client to see what happen ?

Who disconnect the connection ?