Netduino home hardware projects downloads community

Jump to content

The Netduino forums have been replaced by new forums at This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

Larre's Content

There have been 5 items by Larre (Search limited from 17-May 21)

By content type

See this member's

Sort by                Order  

#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)

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.

#55183 Error(?) using WebRequest

Posted by Larre on 04 January 2014 - 11:06 AM in General Discussion



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


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:

Response: HTTP/1.1 200 OK
Connection: close
Cache-Control: no-cache
Response body:
When I look at the content length in debug it has a value of -1 although I actually get a response body.
My guess is that there is something missing in the headers that makes my code break.


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-ENET that 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

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.