Main Site Documentation

G120HDR - reliable web server?


#1

Hello,
I have problems with web server on my G120HDR. After couple of requests web server always stops responding. Is there any reliable web server running on top of mnfm? Can I use Gadgeteer.WebServer? Thank you!


#2

@ Adam - Can you post a minimal program that reliably shows the issue you’re having?


#3

Hello,
I have serious problems with sockets. Always, after about one hundred requests main loop of my web server freezes (comment in my code below). I would appreciate any help…

Firmware version:

4.3.6.

Hardeare configuration:

G120HDR Module Rev2
MicroSD Card Module 1.2
CAN DW Module 1.2
ENC28 Module 1.1

I have read very long discusion about nearly the same issues what I have: https://www.ghielectronics.com/community/forum/topic?id=12342&page=1
Unfortunatelly I didn’t found solution. My code is here:


//ThreadStart method
private void StartServer()
        {
            socket.Listen(int.MaxValue);
            while (!cancel)
            {
                bool pollOk = false;
                try
                {
                    pollOk = socket.Poll(-1, SelectMode.SelectRead);     //stops here forever
                    Debug.Print(counter++.ToString());
                }
                catch (Exception e)
                {
                    //No exceptions here
                    Debug.Print(e.Message);
                    return;
                }
                if (pollOk)
                {
                    processRequest(this.socket.Accept());
                }
            }
        }

Output from VS (last few lines:)
0
1


330
331
332
File length 1476 <---------successfully returned file
333
334
335
File length 1476 <---------successfully returned file
336
337
File length 1476 <---------successfully returned file
338
339
340
341
342
File length 1476
343 <--------- End of story…

I am also reading data from CAN bus every two seconds. It is realized by Threading.Timer. I think that reading CAN bus has minimal impact.


#4

@ Adam - To be sure, can you take everything out of your program except networking?


#5

Socket snippet is confusing me…

You do a listen on the socket, turning it into a socket for listening for incoming connections.

You then wait on the listening socket for something to read?

Usually after a socket has been made into a listener, you do an Accept() against it, which returns a new session socket when a new connection is made. You would then do reads against the new session socket.


#6

Code copied from here also didn’t work.

I have just created new project with only web server. No CAN Bus, no File streams. Few requests and bye bye…

On the web browser side i have page with ajax like:
[em]

Home
[/em]

I am curious if problems causes HW or SW.¨


#7

@ Adam - are you asking us to debug a web server you found on CodePlex?

I think you will get better responses if you make you requests for assistance more specific.