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
- → Viewing Profile: Posts: Larre
The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
Community Stats
- Group Members
- Active Posts 11
- Profile Views 5838
- Member Title Member
- Age Age Unknown
- Birthday Birthday Unknown
-
Gender
Not Telling
0
Neutral
User Tools
Friends
Larre hasn't added any friends yet.
Posts I've Made
In Topic: WebRequest Timeout property doesn't work
08 October 2014 - 07:29 AM
In Topic: Error(?) using WebRequest
04 January 2014 - 11:06 AM
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.
In Topic: Error(?) using WebRequest
02 January 2014 - 09:29 AM
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:
"temperature
60.5000"
- Netduino Forums
- → Viewing Profile: Posts: Larre
- Privacy Policy