Thanks for reply, I have done the same workaround -> since could not find better one, but unfortunately If remote host replies to ping does not mean, that remote webserver is running
- Netduino Forums
- → jur's Content
jur's Content
There have been 4 items by jur (Search limited from 01-July 23)
#60366 WebRequest Timeout property doesn't work
Posted by jur on 08 October 2014 - 06:16 AM in Netduino Plus 2 (and Netduino Plus 1)
#60194 WebRequest Timeout property doesn't work
Posted by jur on 22 September 2014 - 09:48 PM in Netduino Plus 2 (and Netduino Plus 1)
I have been bothering with this same issue for couple of hours with no result. I want to log to my local PHP webservice (which is deliberately offline for testing purposes) unfortunately Netduino does not throw timeout exception, but it hangs on this line even though timeout is set to 5000 ms.
HttpWebResponse response = (HttpWebResponse) webrequest.GetResponse();
I include my piece of code:
try { if (_isNetworkAvailable) { HttpWebRequest webrequest = (HttpWebRequest) HttpWebRequest.Create("http://" + server + url); webrequest.Method = "GET"; webrequest.Timeout = 5000; webrequest.KeepAlive = false; HttpWebResponse response = (HttpWebResponse) webrequest.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { using (var reader = new StreamReader(response.GetResponseStream())) { var buffer = new char[5]; var builder = new StringBuilder(); while (reader.Read(buffer, 0, 5) > 0) builder.Append(buffer); reader.Close(); reader.Dispose(); response.Close(); response.Dispose(); return builder.ToString(); } } else { return null; } } else { throw new Exception("Network cable unavailable"); } } catch (WebException e) { if (e.Status == WebExceptionStatus.ProtocolError) { } return null; } catch(Exception ex) { Debug.Print(ex.Message); return null; }
#60184 HttpWebRequest GetResponse Error
Posted by jur on 22 September 2014 - 06:33 PM in General Discussion
I would also join to whitecap's question:
Is there any way to use the netmf_toolbox_http_client with a timeout (like httpWebRequest)? If the site does not respond the client appears to wait indefinitely.
Thanks
JUR
#55809 Netduino + RF receiver
Posted by jur on 02 February 2014 - 12:14 PM in Project Showcase
Did you anyhow found out how to decode data from Oregon wireless temp sensor?
- Netduino Forums
- → jur's Content
- Privacy Policy