Can't get very most basic web server to run on 4.3.4

This is probably painfully basic and I have looked in the documentation for guidance. However most of it is for 4.2 or 4.3.3 with significant differences for 4.3.4.

Raptor with an ENC28 module on Socket 1 (tried 3 as well) and a USB/Power module on Socket 8.

I can ping the board and it shows up in my router’s wired device list.


    public partial class Program
    {

        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            Debug.Print("Program Started");

            ethernet.UseThisNetworkInterface();
            ethernet.NetworkSettings.EnableStaticIP("10.0.0.20", "255.255.255.0", "10.0.0.1");
            ethernet.NetworkInterface.EnableStaticDns(new String[] { "10.38.44.1", "10.0.0.1" });

            ethernet.NetworkUp += ethernet_NetworkUp;
            ethernet.NetworkDown += ethernet_NetworkDown;

            while (true)
            {
                if (ethernet.IsNetworkUp) break;
                Thread.Sleep(1000);
                Debug.Print("Waiting");
            }

            Thread.Sleep(5000);

            Gadgeteer.Networking.WebServer.StartLocalServer(ethernet.NetworkSettings.IPAddress, 80);

            Gadgeteer.Networking.WebEvent hello;
            hello = Gadgeteer.Networking.WebServer.SetupWebEvent("hello");
            hello.WebEventReceived += new WebEvent.ReceivedWebEventHandler(hello_WebEventReceived);
        }

        void ethernet_NetworkDown(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {
            Debug.Print("Down!");
        }

        void ethernet_NetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {
            Debug.Print("Up!");
        }

        void hello_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
        {
            Debug.Print("hello");
            string content = "<html><body><h1>Hello World!!</h1></body></html>";
            byte[] bytes = new System.Text.UTF8Encoding().GetBytes(content);
            responder.Respond(bytes, "text/html");
        }

When I run this I get the following in the output window:

Program Started
Waiting
Waiting
Web server started at http://10.0.0.20:80/
Down!
Up!
The thread ‘’ (0x3) has exited with code 0 (0x0).

Which seems fine. It then sits until I access from a browser:

http:\10.0.0.20\hello or http:\10.0.0.20:80/hello or any other combination of / and .

at which point in the output window I get:

#### Exception System.IndexOutOfRangeException - 0xa9000000 (6) ####
#### Message: 
#### Gadgeteer.Networking.Responder::FindHeaderSection [IP: 0034] ####
#### Gadgeteer.Networking.Responder::Parse [IP: 004b] ####
#### Gadgeteer.Networking.WebServerManager+Server::ProcessRequest [IP: 0090] ####

A first chance exception of type ‘System.IndexOutOfRangeException’ occurred in Gadgeteer.WebServer.dll
The thread ‘’ (0x6) has exited with code 0 (0x0).

So it appears that something gets through but is not being handled properly.

If I unplug the Ethernet and plug it in after the system boots, there is no difference except a whole bunch more “Waiting”

Looks like there is a bug in Gadgeteer’s Responder implementation. You can include Gadgeteer source code and see where that exception is thrown.

I would also suggest you try to not block the ProgramStarted with any form of while loop or waiting until your connection has stabilised. Set up handlers, and let it finish, so that the scheduler can get set up properly. http://blogs.msdn.com/b/net_gadgeteer/archive/2011/12/19/why-not-while-true.aspx

This thread explains the bug and the fix for it:
https://www.ghielectronics.com/community/forum/topic?id=16375&page=1#msg162452

And this one explains in detail how to implement it :
https://www.ghielectronics.com/community/forum/topic?id=16330&page=1#msg162088