I had the same issue but I solved it in another way. I did the webrequest in a separate thread and used thread.join(myTimeout) to make it stop if it hanged.
- Netduino Forums
- → Larre's Content
Larre's Content
There have been 5 items by Larre (Search limited from 04-June 23)
#60367 WebRequest Timeout property doesn't work
Posted by Larre on 08 October 2014 - 07:29 AM in Netduino Plus 2 (and Netduino Plus 1)
#55183 Error(?) using WebRequest
Posted by Larre on 04 January 2014 - 11:06 AM in General Discussion
Solved!
Still think that there was a problem with headers in the previous test but I solved it using another way (as always) see below.
public double GetTemperature(string address) { var request = (HttpWebRequest)WebRequest.Create(_url + address); request.Timeout = 3000; double returnTemperature = -99D; try { using (var stream = request.GetResponse().GetResponseStream()) using (var reader = new StreamReader(stream)) { char[] tempChar = new char[5]; reader.Read(tempChar, 0, 5); var temperature = new string(tempChar); ... } } }
Instead of "ReadToEnd" I am using the ordinary reader and in this specific case I only need the first few chars of the response.
#55135 Error(?) using WebRequest
Posted by Larre on 02 January 2014 - 09:29 AM in General Discussion
Hi,
No exception, it just hangs when it hits the GetResponseStream(). I haven't tried adjusting the Timeout since I seem to get a response straight away.
When I debug the response I can see that Content Length is set to -1 and Content Type is an empty string.
The expected response is really small, se below:
#55095 Error(?) using WebRequest
Posted by Larre on 01 January 2014 - 08:48 AM in General Discussion
Hello all,
I am trying to do a WebRequest from my Netduino to poll a string from another system. I am using the code below to perform the request:
public double GetTemperature(string address) { var request = WebRequest.Create(_url); var response = request.GetResponse(); request.Dispose(); var sr = new StreamReader(response.GetResponseStream()); var source = sr.ReadToEnd(); response.Dispose(); sr.Dispose(); ... }
Problem is my code gets stuck at "GetResponseStream()".
Response headers:
Any ideas how to make this work?
BR Larre
#53215 Get parts of xml stream from web
Posted by Larre on 15 October 2013 - 07:47 PM in Netduino Plus 2 (and Netduino Plus 1)
Hi fellow Netduiners,
I am stuck in my project.
I have a onewire server called OW-SERVER-ENETthat produces an xml file of all my connected onewire devices and their value.
My goal is to read the xml file and get values from some of these devices and handle it in my Netduino.
However when running a WebRequest I only get part of the page. My guess is that I am getting too much data back for the Netduino to handle.
Can someone put me in the right direction of how to handle this? Is it possible to get certain parts back from a WebRequest?
Anyone else familiar with OW Server or OneWire?
BR Larre
- Netduino Forums
- → Larre's Content
- Privacy Policy