1 of 1 people found this helpful
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?
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
Kindly follow the approach of reinitializing the client if the socket close error is encountered.
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?