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.

R.Ganesh

Member Since 19 Apr 2011
Offline Last Active Oct 03 2012 09:19 AM
-----

Topics I've Started

HttpListener does not respond

01 March 2012 - 06:20 PM

Hi all,

I have a web server running on an Netduino plus using the HttpListener listening for client requests and responding with a simple html. I am investigating a problem at a project installation, where the web server stops responding after few days of working (client requests are not so often, once in a day or even longer). I tried to reproduce the problem but did not succeed. However, during testing I noticed that one way to make the web server non-responsive is to send a burst of requests - i did this by keeping F5 key pressed in the internet explorer (continously refereshes). After this, the web server stops responding. First, the code (simplified):
internal static void RunServer()
        {
            HttpListener listener = new HttpListener("http", -1);
            listener.Start();

            while (true)
            {
                try
                {
                    Debug.Print("Listening..");
                    HttpListenerContext context = null;
                    context = listener.GetContext();
                    Debug.Print("Received request from " +  context.Request.UserHostAddress.ToString());
                    context.Response.ContentType = "text/html";
                    string html = "<html><p>Hello World " + DateTime.Now.ToString() + "</p></html>";
                    System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
                    byte[] messageBody = encoding.GetBytes(html);
                    context.Response.OutputStream.Write(messageBody, 0, messageBody.Length);

                    if (context.Response != null)
                        context.Response.Close();
                }
                catch (Exception e)
                {
                    Debug.Print("Exception occured! " + e.Message);

                    PowerState.RebootDevice(true, 1000);
                }
            }
        }
Next, the version information:

.NetMF v4.1.2821.0
NetduinoPlus, Build Date:Mar 26 2011 02:15:31
ARM Compiler version 400902
TinyCLR (Build 4.1.2821.0)

Finally, the exception (as seen on MF Deploy console)

Listening..
#### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (5) ####
#### Message:
#### Microsoft.SPOT.Net.SocketNative::accept [IP: 0000] ####
#### System.Net.Sockets.Socket::Accept [IP: 001c] ####
#### System.Net.HttpListener::AcceptThreadFunc [IP: 0020] ####
#### SocketException ErrorCode = 10056
Received request from 4.0.0.0
#### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (4) ####
#### Message:
#### Microsoft.SPOT.Net.SocketNative::send [IP: 0000] ####
#### System.Net.Sockets.Socket::Send [IP: 0018] ####
#### System.Net.Sockets.NetworkStream::Write [IP: 0051] ####
#### System.Net.OutputNetworkStreamWrapper::Write [IP: 0017] ####
#### System.Net.HttpListenerResponse::SendHeaders [IP: 0021] ####
#### System.Net.OutputNetworkStreamWrapper::Write [IP: 000d] ####
#### NetduinoTest.WebServer::RunServer [IP: 0074] ####
#### SocketException ErrorCode = 10056
Exception occured! Exception was thrown: System.Net.Sockets.SocketException

Any pointers on this would be really helpful to me! Thank you!

Ganesh

Energy meter

01 May 2011 - 07:04 PM

Hi all, I ported the current & voltage measure code written for Arduino in the Open Energy Monitor project (http://openenergymonitor.org/emon/). Hope you will find it useful. Cheers Ganesh

RFM12B Wireless module with Netduino Plus

26 April 2011 - 08:12 AM

Hello all, This is my first project with Netduino platform (using netduino plus variant) - I am trying to integrate the Hope RF's RFM12B module to netduino plus (there is are existing examples for Arduino, AVR etc.). I wrote my own .net mf library for this purpose so that it is easier to debug and change the low level functions. Everything works fine, except that the max baud rate achievable with Netduino plus is 2400 bps. The same code when tested on FEZ Cobra works fine for baud rate upto 115.2 kbps. My test setup: Trying to send 16 bytes. Netduino Plus (Tx) ------> FEZ (Rx) = Max 2400 bps FEZ (Tx) ----------> Netduino Plus (Rx) = Max 2400 bps Netduino Plus(Tx) --------> Netduino Plus (Rx) = Max 2400 bps FEZ (Tx) -----------> FEZ (Rx) = Max 115.2 Kbps. I tried to find out the difference between the two platforms and what seems to be a possible cause is that the netduino plus is slower when it comes to SPI clock frequency (200 kHz, as compared to 20 MHz of FEZ Cobra) and also the time required to accomplish an input port read (to check the RFM ready state) is appox 1.5 ms in netduino plus (as compared to 200 uS in FEZ). The slower read of the RFM's ready state results in longer time required to send the data payload. When only one or two bytes is the length of the payload, the netduino plus is able to send the packets at baud rate of 4800 bps max. Can this issue be really due to slower processing on Netduino? Thanks a lot for any help or pointers! Cheers Ganesh

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.