Overcoming socket close (7014) error

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

cross mob
agmi_3321141
Level 4
Level 4
5 likes given First like received First like given

Hi,

When sending HTTP packets, the server connection works fine for a while and then I start seeing socket closed error (7014). It doesn't recover from this error. I am using the http_client connect and disconnect api (with TLS). Any inputs on how to gracefully recover from this condition? I can deinit the http client which deletes the socket

0 Likes
1 Solution

Kindly follow the approach of reinitializing the client if the socket close error is encountered.

View solution in original post

0 Likes
5 Replies
PriyaM_16
Moderator
Moderator
Moderator
250 replies posted 100 replies posted 50 replies posted

Hello,

The correct sequence would be to initialize the connection again after it has failed once. You are already following this sequence using http_client_connect and disconnect APIs. You can keep a check if the network is still up before initializing the connection again using wiced_network_is_ip_up API. In case it is not up, you can insert a delay of few milliseconds and try again. The demo.iot_getway application has similar such implementation. Please have a look at the iot_geteway application.

Besides can you make sure the server is up and responding, by sending ping messages through another client(ex. curl )?

Thanks for the suggestions. The wiced_network_is_ip_up API would check if the interface is connected but I don't think that is exactly my issue. It looks like the server closes the socket for some reason and if I re-initialize the socket(deinit and then init http client), I can send requests successfully. In this scenario, I think this the only way is to look for a socket close error code and re-initialize the client?

0 Likes

you should close the socket sone time what does happen when the code compiles then after complication the compile process socket still opens. the problem occurs encounter socket in Python. i have also faced this issue when i work for client website name with Write my paper online in this project i face this issue and i was irritated because the error is just out of control.

the solutions of the problem here is the dirty socket closing which occurs when the script crashes without the proper TCP connection shutdown sequence. Thankfully there's a simple solution which tells the kernel to ignore the fact the socket is already in use (the port it's bound to):

sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

use this the problem should be solved

0 Likes

Kindly follow the approach of reinitializing the client if the socket close error is encountered.

0 Likes
SiSa_3185206
Level 4
Level 4
10 likes received First like received First like given

There are many factors which may effect socket closure while the connection is alive.

In order to understand where you are making any mistake, you have to answer to some of the following questions.

Which application code are you using??

Are you using the snip/https_server and client code or something of your own??

Please check if you are passing appropriate socket parameters while initializing.

What is the API are you using to initialize a socket?

0 Likes