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

cross mob
hoainguyen265
Level 3
Level 3
5 likes given 25 sign-ins 10 replies posted

I use module CYW54907 with 

WICED Version: Wiced_006.006.000.0009 

 I alway got the socket disconnect event when download about 1.7Mb firmware file from server at when the remaining data about 200kb. If the firmware file size smaller, about 1Mb every thing is ok.

With 1.7Mb file, if i don't write the data to the flash to reduce the time, it's seem ok too.

I also test and download file successfully with the python script.

0 Likes
1 Solution

Hi @Phanindra_I , thanks for your support.

Finally, i have check with the server team and figure out that they have a timeout config.

So i have to use "Range" header in http request to download the large file.

View solution in original post

9 Replies
Phanindra_I
Moderator
Moderator
Moderator
250 sign-ins 10 likes given 25 likes received

Hello,

Please post the details of your application? Is it a TCP connection? Is 54907 a http client? After start of file download, how much time does it take for socket disconnection usually?

Thanks

Yes, I use http client request to download file from server. The disconnection time is not the same, about around 2 minute or more.

This is connection header:

HTTP/1.1 200 OK
Date: Wed, 31 May 2023 04:22:51 GMT
Content-Type: application/octet-stream
Content-Length: 1311924
Connection: keep-alive
Server:
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Accept-Ranges: bytes
Age: 60
Vary: Accept-Charset,Accept-Encoding,Accept-Language,Accept
Crc32: 907029372
Via: 1.1 xx.xx.com
X-XSS-Protection: 1; mode=block
x-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Referrer-Policy: strict-origin-when-cross-origin
Via: 1.1 xx.xx.com
Set-Cookie: AWSALBAPP-0=_remove_; Expires=Wed, 07 Jun 2023 04:22:51 GMT; Path=/
Set-Cookie: AWSALBAPP-1=_remove_; Expires=Wed, 07 Jun 2023 04:22:51 GMT; Path=/
Set-Cookie: AWSALBAPP-2=_remove_; Expires=Wed, 07 Jun 2023 04:22:51 GMT; Path=/
Set-Cookie: AWSALBAPP-3=_remove_; Expires=Wed, 07 Jun 2023 04:22:51 GMT; Path=/

0 Likes
Phanindra_I
Moderator
Moderator
Moderator
250 sign-ins 10 likes given 25 likes received

Hi,

I am assuming that you're using a custom developed application. If not, please let me know in case you're using a code example of WICED. I can see that connection is keep-alive so ideally socket disconnection is not expected. You can enable logs in "wiced_defaults.h" file (general library prints, network stack prints). They might give some info on disconnection.

Thanks

This is connection header that i fetch from the host @Phanindra_I 

Based on log, i check that the disconnected event from:

internal_nx_tcp_socket_disconnect_callback

 I wonder if i have to add "Connection: keep-alive" in my request header and enable keep-alive for my tcp socket?

0 Likes
Phanindra_I
Moderator
Moderator
Moderator
250 sign-ins 10 likes given 25 likes received

Hi,

In that case, keep-alive should be enabled on the client side as well. If not enabled, connection gets timed out after a particular amount of time which explains socket disconnection.

Thanks

Hi @Phanindra_I i just added the  "Connection: keep-alive" to request header and try to turn on keep-alive timer but got no luck.

in 

wiced_result_t http_client_connect( http_client_t* client, const wiced_ip_address_t* server_ip, uint16_t port, http_security_t security, uint32_t timeout_ms );

 I try to set the keep-alive value

client->socket.socket.nx_tcp_socket_keepalive_enabled = 1;
client->socket.socket.nx_tcp_socket_keepalive_retries = 5;
client->socket.socket.nx_tcp_socket_keepalive_timeout = 10;

printf("socket info before %d %lu %lu\r\n",
client->socket.socket.nx_tcp_socket_keepalive_enabled,
client->socket.socket.nx_tcp_socket_keepalive_retries,
client->socket.socket.nx_tcp_socket_keepalive_timeout);

if ( ( result = wiced_tcp_connect( &client->socket, server_ip, port, timeout_ms ) ) != WICED_SUCCESS )
{
wiced_tls_deinit_context( client->tls_context);
return result;
}

printf("socket info after %d %lu %lu\r\n",
client->socket.socket.nx_tcp_socket_keepalive_enabled,
client->socket.socket.nx_tcp_socket_keepalive_retries,
client->socket.socket.nx_tcp_socket_keepalive_timeout);

 But in log i can see:

socket info before 1 5 10
nx_tcp_socket_send err=0
nx_tcp_socket_receive err=0
nx_tcp_socket_receive err=0
nx_tcp_socket_receive err=0
nx_tcp_socket_receive err=0
nx_tcp_socket_receive err=0
nx_tcp_socket_receive err=0
nx_tcp_socket_receive err=0
nx_tcp_socket_send err=0
nx_tcp_socket_send err=0
nx_tcp_socket_send err=0
nx_tcp_socket_receive err=0
nx_tcp_socket_receive err=0
socket info after 1 0 7200
i:connectHttpClient http_client_connect completed ret=0 0
d:HTTP_CONNECTED at 117109

So this mean my value set to socket is not work. Could you give me the proper way to do that?

0 Likes

Hi @Phanindra_I I found this topic 

https://community.infineon.com/t5/Wi-Fi-Combo/43907-The-TCP-client-cannot-use-the-Keepalive-function...

Could you support me to turn-on keep-alive feature on client side with CYW54907?

0 Likes
Phanindra_I
Moderator
Moderator
Moderator
250 sign-ins 10 likes given 25 likes received

Hello,

You can see from the logs "socket info after 1 0 7200" that keep-alive is indeed enabled and the keep-alive timeout is set to 120 mins. These are the values with which the static library files of NetX  provided in WICED are compiled.

Thanks

0 Likes

Hi @Phanindra_I , thanks for your support.

Finally, i have check with the server team and figure out that they have a timeout config.

So i have to use "Range" header in http request to download the large file.