So, my application exchanges requests and responses with the server (no problem) until the Internet connection dies for a couple of seconds, and then returns. Then this code:
response = (HttpWebResponse)request.GetResponse();
will throw an exception with a status like ReceiveFailure , ConnectFailure , KeepAliveFailure , etc.
Now it is very important that if the Internet connection returns, I can continue to communicate with the server, otherwise I will have to start from the very beginning, and this will take a lot of time.
How could you resume this conversation when the Internet returns?
At the moment, I continue to test the possibility of communication with the server until this is possible (at least theoretically). My code attempt looks like this:
try { response = (HttpWebResponse)request.GetResponse(); } catch (WebException ex) {
However, the problem is that the second try-catch statement continues to throw an exception, even when the Internet has returned.
What am I doing wrong? Is there any other way to do this?
Thanks!
source share