• AVR Freaks

Hot!Harmony 2 - Web server not servering files

Author
Soren.Bang
Starting Member
  • Total Posts : 45
  • Reward points : 0
  • Joined: 2012/10/10 13:01:51
  • Location: Denmark
  • Status: offline
2019/10/17 09:10:53 (permalink)
0

Harmony 2 - Web server not servering files

I use the webserver on a PIC32MX695 based project to allow the user to change IP settings etc. all very basic and based on the web server demo (nvm/mpfs).
I have had it working for quite a while but I managed to break it and/or misconfigure the http server.
when I connect to the webserver (chrome or edge) it just times out, but if I request a file which is _not_ on the web server I get a 404 error so the http server is running and if I try to request a file in the /protect folder I get prompted for login.
 
I have tried to replace the 'custom_http_app.c' file with the original file form the demo and the corresponding mpfs_img2.c generated by the mpfs converter tool based a copy of the original website folder- but with the same result.
 
Any suggestions and/or advice would by much appriciated.
 
Søren
 

 
 

Attached Image(s)

#1

13 Replies Related Threads

    campbellCustom
    Starting Member
    • Total Posts : 69
    • Reward points : 0
    • Joined: 2014/08/30 14:35:35
    • Location: 0
    • Status: offline
    Re: Harmony 2 - Web server not servering files 2019/10/17 09:31:07 (permalink)
    0
    I had a similar problem that involved the settings in the file system. I believe I had to increase the number of files allowed to open.
     
    Perhaps examine the demo application check boxes concerning MPFS and SYS_FS
    #2
    Soren.Bang
    Starting Member
    • Total Posts : 45
    • Reward points : 0
    • Joined: 2012/10/10 13:01:51
    • Location: Denmark
    • Status: offline
    Re: Harmony 2 - Web server not servering files 2019/10/17 11:02:19 (permalink)
    0
    Dear Campbell
     
    Thank you for swift response.
     
    The standard SYS_FS_MAX_FILES is set to 25 and I only have 21 files on my webserver so I guess that should be good.
    How many files did you have in your webserver and what setting did you use for that to work ?
     
    I have been through settings for both the NVM driver and the File System and I use the exact same settings as on the web server demo.
     
    Regards
     
    Søren
     
    #3
    rainad
    Moderator
    • Total Posts : 1225
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: online
    Re: Harmony 2 - Web server not servering files 2019/10/17 12:35:12 (permalink)
    0
    Can you please test what happens if just want a specific file? Preferably non-compressed, if you have something like that.
    For example: http://myboard/test.txt
    Also a wireshark log would be useful.
     
    #4
    Soren.Bang
    Starting Member
    • Total Posts : 45
    • Reward points : 0
    • Joined: 2012/10/10 13:01:51
    • Location: Denmark
    • Status: offline
    Re: Harmony 2 - Web server not servering files 2019/10/17 13:09:48 (permalink)
    0
    Hi Rainad
     
    I have created text file (test.txt) containing the text 'test' and placed it in the root folder.
     
    I have reprogrammed the board (10.222.2.75) and connected to webserver from my win10pro pc (10.222.2.67).
    The communication on port 30303 and 30304 is our in-house discovery tool.
     
    I cannot access the test.txt filer either but a request for text.txt (no file with that name on the web server) I get '
    404: File not found'
    I have attached the wireshark log file for a start up sequence, http request for http://10.222.2.75 and for http:// 10.222.2.75/test.txt
     
    Regards
     
    Søren
    #5
    rainad
    Moderator
    • Total Posts : 1225
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: online
    Re: Harmony 2 - Web server not servering files 2019/10/17 13:56:48 (permalink)
    0
    Since the HTTP server replies with 404, it means the communication with the board is fine.
    Can you please check that the SYS_FS_Mount() operation is successful?
    If that is fine, try to open a file directly in your code, as a test.
     
    #6
    Soren.Bang
    Starting Member
    • Total Posts : 45
    • Reward points : 0
    • Joined: 2012/10/10 13:01:51
    • Location: Denmark
    • Status: offline
    Re: Harmony 2 - Web server not servering files 2019/10/18 00:04:28 (permalink)
    0
    Hi Rainad
     
    The SYS_FS_Mount() does indeed succeed or I my main application would not start, which it does.
     

        switch (appData.state) {
                /* Application's initial state. */
            case APP_MOUNT_DISK:
                if(SYS_FS_Mount(SYS_FS_NVM_VOL, LOCAL_WEBSITE_PATH_FS, MPFS2, 0, NULL) == 0)
                {
    // SYS_CONSOLE_PRINT("SYS_Initialize: The %s File System is mounted\r\n", SYS_FS_MPFS_STRING);
                    appData.state = APP_STATE_INIT;
                }
                break;

            case APP_STATE_INIT:
            {
                appData.state = APP_TCPIP_WAIT_FOR_TCPIP_INIT;
    // SYS_CONSOLE_MESSAGE(" APP: Initialization\r\n");
                processcounter = 0;
                break;
            }

     
    I assumed that the file system is correctly up and running when the HTTP server sends a 404 for a file request on a file which is not present and something else when the file requested (fx. index.htm) is present.
     
    I have tried to open my test file (test.txt) and that is successful:

                if(SYS_FS_Mount(SYS_FS_NVM_VOL, LOCAL_WEBSITE_PATH_FS, MPFS2, 0, NULL) == 0)
                {
    // SYS_CONSOLE_PRINT("SYS_Initialize: The %s File System is mounted\r\n", SYS_FS_MPFS_STRING);
                    SYS_FS_HANDLE fileHandle;
                    fileHandle = SYS_FS_FileOpen("/mnt/mchpSite1/test.txt",(SYS_FS_FILE_OPEN_READ));

                    if(fileHandle != SYS_FS_HANDLE_INVALID)
                        {
                        // File open succeeded.
                        PIC_USBOn(); // USB LED ON to indicate File opened successfully
                        while(1); // halt code
                        }
                    else
                        {
                        // File open failed.
                        while(1); // halt code
                        }
                    
                    appData.state = APP_STATE_INIT;
                }

     
    Looking in the wireshark log there is the regular 'GET / HTTP/1.1' from the browser (chrome) which is shortly after followed by a 'HTTP/1.1 200 OK  Connection Close' message from the webserver - This does not seem right to me as that package is only 90 byte but it should have contained data for the 'index.htm' and the 'HTTP/1.1 200 OK  Connection Close'.
     
    Regards
     
    Søren
    #7
    rainad
    Moderator
    • Total Posts : 1225
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: online
    Re: Harmony 2 - Web server not servering files 2019/10/18 08:02:39 (permalink)
    0
    The http server uses a call to SYS_FS_FileOpen_Wrapper() to request a file from the SYS_FS.
    Please put a break point in this wrapper function (in common/sys_fs_wrapper.c) and then request the test.txt file from the browser.
    The execution should reach the break point. You can take a look at what exactly is requested from the SYS_FS and why the call fails. Probably something is not configured properly.
     
     
    #8
    Soren.Bang
    Starting Member
    • Total Posts : 45
    • Reward points : 0
    • Joined: 2012/10/10 13:01:51
    • Location: Denmark
    • Status: offline
    Re: Harmony 2 - Web server not servering files 2019/10/23 06:55:28 (permalink)
    0
    Dear Rainad
     
    I have been looking through the file open and file reading processes and they all execute without error so the files are being read from flash.
    Being a little bit desperate I installed a fresh copy of harmony 2.06 in a new folder (c:\microchip\harmony_b\v2_06) and compiled the 'web_server_nvm_mpfs' demo with one change - The PHY changed to the KSZ8863RLL.
    That works and the demo web site is running with live data and all.
    I then recreated the mpfs_img2.c file with the 'Microchip mpfs generator' based on data in the 'web_pages' folder in the demo project folder.
    Then I recompiled the demo project and now I have the same problem as with my project code - No web pages are shown in my browser (chrome), but requesting a file that is not in the web_pages folder gives : '404: File not found / Use MPFS Upload to program web pages' as it should (http server is running).
    The 'Microchip mpfs generator' updates the following files as it should: 'http_print.c', 'http_print.idx', '\web_pages\DynRcrd.bin' and 'web_pages\FileRcrd.bin'.
     
    Does this by any change shed some light on the issue that I'm chasing ?
     
    I have set 'Microchip mpfs generator' output option to 'PIC32Image'.
     
    Regards
    Søren 
     
     
    #9
    rainad
    Moderator
    • Total Posts : 1225
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: online
    Re: Harmony 2 - Web server not servering files 2019/10/23 08:52:12 (permalink)
    0
    If I understand correctly, if you replace in the project the mpfs_img2.c, http_print.c, dyn rcrd.bin and filercrd.bin with the original ones and rebuild everything works fine.
    The same project does not work with the new web pages.
    Seems to be an issue with the mpfs_generator then.
    Do you get any output when you're asking for some particular page? Not necessarily index.htm but a simpler page, without dynamic content, etc. It's not 404, what is it, is there any output?
     
     
    #10
    Soren.Bang
    Starting Member
    • Total Posts : 45
    • Reward points : 0
    • Joined: 2012/10/10 13:01:51
    • Location: Denmark
    • Status: offline
    Re: Harmony 2 - Web server not servering files 2019/10/23 10:21:31 (permalink)
    0
    I did the test by using the original mpfs_img2.c, http_print.c, dyn rcrd.bin and filercrd.bin files which works but when the mpfs generator has updated the files then they don't work,
     
    if I ask for mchp.gif I get no response same as if I ask for index.htm or \protect\config.htm.
     
    Regards
     
    Søren
     
    #11
    Soren.Bang
    Starting Member
    • Total Posts : 45
    • Reward points : 0
    • Joined: 2012/10/10 13:01:51
    • Location: Denmark
    • Status: offline
    Re: Harmony 2 - Web server not servering files 2019/10/23 10:45:43 (permalink)
    4 (1)
    I have just tried an older version of the mpfs generator (ver 2.33) instead of ver 2.34 included in harmony 2.06 and now the web pages are shown in the browser with live data and all
     
     
    #12
    moser
    Super Member
    • Total Posts : 511
    • Reward points : 0
    • Joined: 2015/06/16 02:53:47
    • Location: Germany
    • Status: offline
    Re: Harmony 2 - Web server not servering files 2019/10/28 04:27:49 (permalink)
    0
    There was something wrong with MPFS Generator v2.34. But I don't remember the details anymore.  I think it was described here: 
     
    WORKAROUND FOUND: Dynamic Variables Problem - MPFS Generator 2.34 is buggy.
    https://www.microchip.com/forums/FindPost/1019885
     
     
    PS: If you start something new, you should consider to use the newer http server "HTTP Net Module" instead of the old "HTTP Module". I think the example is "web_net_server_nvm_mpfs".
    post edited by moser - 2019/10/28 04:35:58
    #13
    Soren.Bang
    Starting Member
    • Total Posts : 45
    • Reward points : 0
    • Joined: 2012/10/10 13:01:51
    • Location: Denmark
    • Status: offline
    Re: Harmony 2 - Web server not servering files 2019/10/28 05:58:58 (permalink)
    0
    Dear Mose
     
    Thank you for your information - When I realized that the MPFS was faulty I managed to find a thread on the forum from back in 2017 - So the issue with the MPFS generator 2.34 is 2 years old and has not been fixed to this day.
     
    Regards
     
    Søren
    #14
    Jump to:
    © 2019 APG vNext Commercial Version 4.5