Main Site Documentation

Problem with "HelloWebServer" project. (spider getting started)


#1

The error is simple, instead of
Web server started at http://192.168.1.106:80/

like is says in the example I’m getting

Web server started at http://0.0.0.0:80/

And there’s nothing at that address.
The Ethernet cable is plugged. Using the spider mainboard.


#2

0.0.0.0 indicates you don’t have a network address. Are you using DHCP or fixed IP address? And have you confirmed networking works in your environment with either other apps using networking or through debug? This thread https://www.ghielectronics.com/community/forum/topic?id=10855 has a few example code blocks you can use to test and confirm networking works before you go to a web server


#3

WAN Connection Type says DHCP
on the router options.


#4

WAN implies the ADSL or cable connection, not your LAN - but that is not what I meant.

Your device (your Fez) has to obtain an address. Either that address is manually assigned to it, in code or through the configuration app/s, or it is assigned by DHCP. You need to know which one to choose - if this is a home network you can be pretty sure that DHCP will be the right answer.

You then have to make sure the code you implement uses your chosen address mechanism.

You then have to make sure that the application works to get the address - your 0.0.0.0 shows that this is failing. You need to dig into why, and that other thread I pointed out may have example code so you can try to diagnose where the process may not be working…


#5

@ Brett - The event handler .NetworkUp() is called, that mean that there’s an lan connection, the port is open as well. At the tutorial the author isn’t mention something like that can happen.
At the beginning of the program :

      void ProgramStarted()
        {
            ethernet.UseDHCP();
            ethernet.NetworkUp += new GTM.Module.NetworkModule.NetworkEventHandler(ethernet_NetworkUp);
            ethernet.NetworkDown += new GTM.Module.NetworkModule.NetworkEventHandler(ethernet_NetworkDown);
            led.TurnBlue();
        }

#6

@ andre.m -

        void ethernet_NetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {
            led.TurnGreen();
            
            string ipAddress = ethernet.NetworkSettings.IPAddress;
            Debug.Print(ipAddress);
            WebServer.StartLocalServer(ipAddress, 80);
            sayHello = WebServer.SetupWebEvent("hello");
            sayHello.WebEventReceived += new WebEvent.ReceivedWebEventHandler(sayHello_WebEventReceived);
        }

Output:

Using mainboard GHI Electronics FEZSpider version 1.0
0.0.0.0
Web server started at http://0.0.0.0:80/


#7

NetworkUp() implies there’s a link. Nothing else. As Andre points to you need to know ADDRESS level interactions, so again the earlier link has a great little routine to be used in the network address change event that can help uncover some of that - but I will almost guarantee you’re never hitting that.

If you want to maximise the input, tell us about your network - like whether it’s a home network or a corporate managed network, info on the router you’re talking about, how your PC is configured, what your router can tell you about registered DHCP clients etc. In fact it’s probably worth telling us what mainboard and network module you’re using too in case that’s important.

Edit: just saw your post from a few seconds before mine. The code relies on getting an address when the network state change happens, but that’s not guaranteed. You should move your webserver startup code out of there - and to help diagnose, perhaps if you put in a 10-pass loop with a 10-sec delay between iterations and watch the address value there (or use the addresschange event)


#8

@ andre.m - I took your advice :

 string ipAddress = ethernet.NetworkSettings.IPAddress;
            Debug.Print(ipAddress);
            int i = 0;
            while (ipAddress.Equals("0.0.0.0"))
               
            {
                 ipAddress = ethernet.NetworkSettings.IPAddress;
                i++;
            }
           Debug.Print("i ="+ i.ToString());

i =96
Web server started at http://192.168.1.19:80/

What is your opinion?


#9

@ andre.m - Can’t connect to my webserver using external ip (outside my home network, port is open)


#10

It does. I must point out that if i use:


        static string ipAddress = "192.168.1.13";     
        static int port = 80;                 
        static string subnetMask = "255.255.255.0";    
        static string gatewayAdress = "192.168.1.1"; 
        ethernet_J11D.Interface.Open();
         NetworkInterfaceExtension.AssignNetworkingStackTo(ethernet_J11D.Interface);
         ethernet_J11D.Interface.NetworkInterface.EnableStaticIP(ipAddress, subnetMask, gatewayAdress);
            

I can access my webserver outside of the lan isntead of



 WebServer.StartLocalServer(ipAddress, 80);

#11

@ andre.m - What should i look for?


#12

Router manual should have the information on how to set it up.


#13

@ andre.m - Yep, that was it. Thank you.


#14

Just a suggestion…
Put a pause in your while loop…

Something like thread.sleep(1000) so you are not running a tight loop

Cheers…