Netduino home hardware projects downloads community

Jump to content


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.

Larre

Member Since 10 Dec 2012
Offline Last Active Jul 02 2020 12:35 PM
-----

Posts I've Made

In Topic: WebRequest Timeout property doesn't work

08 October 2014 - 07:29 AM

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.


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"

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.