RTCS HTTPD seconds long delay between connections

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

RTCS HTTPD seconds long delay between connections

Jump to solution
3,383 Views
brianr
Contributor I

I'm running MQX 4.0 using the HTTPD server from the RTCS suite.  I'm serving up some CGI pages.  Specifically, it's JSON formatted data.  I have an AJAX script on another machine that pulls a few of these pages down in succession.  The first page that is pulled down will return very quickly (<200 mS).  Subsequent pages each seem to take right around 3 seconds to be returned to the client.

This is what the call stack from the httpd thread looks like while I'm waiting for data to return:

Thread [ID: 0x10005] (Suspended: Signal 'Process Suspended' received. Description: Process Suspended.)   

    8 DummyFn1() dispatch.S:269 0x0000045e   

    7 _msgq_send_internal() msgq.c:2176 0x000097c0   

    6 _msgq_send_blocked_internal() msgq.c:1992 0x000095d0   

    5 RTCS_cmd_issue() rtcscmd.c:191 0x00028760   

    4 RTCS_selectall() soselall.c:64 0x000273ec   

    3 httpd_server_task() httpd_task.c:244 0x00024fc0   

    2 RTCS_task() rtcstask.c:70 0x0002c930   

    1 _task_exit_function_internal() task.c:2970 0x00008048   

Initially it looked to me like MQX wasn't closing and just waiting for a connection to time out before starting the next one, but I've tweaked just about every #define in MQX that has to do with connection limits or timings and nothing seems to help.

I'm reasonably new to MQX and not an expert on the underpinnings of TCP/IP and HTTP.  Can anyone give any insight or tips on how to troubleshoot this further?  Thanks.

-Brian


Labels (1)
1 Solution
1,976 Views
karelm_
Contributor IV

Hi Brian,

Low performance is known issue of the RTCS web server. However we plan to replace it with a new server version that is in attached ZIP file.

Please take a note that this is preliminary software that is going to be part of one the future MQX release and is not fully tested. To use this new version please follow these steps:

1. Remove following files from RTCS library project:

rtcs/source/httpd/httpd_cnfg.h

rtcs/source/httpd/httpd_mqx.c

rtcs/source/httpd/httpd_mqx.h

rtcs/source/httpd/httpd_poll.c

rtcs/source/httpd/httpd_wrapper.h

2. Replace files in your MQX instalation with files in attached ZIP file.

3. Add files rtcs/source/apps/rtcs_base64.c and rtcs/source/include/rtcs_base64.h to your RTCS library project.

4. Modify file rtcs/include/rtcscfg.h to suit your needs.

5. Recompile RTCS library.

Also be aware that http server API has changed. It now uses only two functions: httpd_init (used to init and start http server) and httpd_release (used to stop http server and free its memory).

Function httpd_init has one parameter of type HTTPD_PARAMS_STRUCT* and returns http server handle. This handle is used as parameter for function httpd_release. I have also attached new httpd server example so you can see how to use this new API properly.

Best regards,

Karel Mozny.

Edit: - Updated zip so there are all files. - Updated required steps.

View solution in original post

9 Replies
1,977 Views
karelm_
Contributor IV

Hi Brian,

Low performance is known issue of the RTCS web server. However we plan to replace it with a new server version that is in attached ZIP file.

Please take a note that this is preliminary software that is going to be part of one the future MQX release and is not fully tested. To use this new version please follow these steps:

1. Remove following files from RTCS library project:

rtcs/source/httpd/httpd_cnfg.h

rtcs/source/httpd/httpd_mqx.c

rtcs/source/httpd/httpd_mqx.h

rtcs/source/httpd/httpd_poll.c

rtcs/source/httpd/httpd_wrapper.h

2. Replace files in your MQX instalation with files in attached ZIP file.

3. Add files rtcs/source/apps/rtcs_base64.c and rtcs/source/include/rtcs_base64.h to your RTCS library project.

4. Modify file rtcs/include/rtcscfg.h to suit your needs.

5. Recompile RTCS library.

Also be aware that http server API has changed. It now uses only two functions: httpd_init (used to init and start http server) and httpd_release (used to stop http server and free its memory).

Function httpd_init has one parameter of type HTTPD_PARAMS_STRUCT* and returns http server handle. This handle is used as parameter for function httpd_release. I have also attached new httpd server example so you can see how to use this new API properly.

Best regards,

Karel Mozny.

Edit: - Updated zip so there are all files. - Updated required steps.

1,976 Views
Tim562
Senior Contributor I

Hi Karel,

     I followed the instructions in your post and when attempting to recompile the RTCS library I get an error stating that the "partition.h" file which is included in the new "include\rtcs25x.h" file cannot be found (started with MQX 3.8.1 on TWRMPC-5125). I've done file searches for this file in the Freescale folder and do not find it. Several other errors follow, but it seems most are associated with the contents of this missing "partition.h" file. Any ideas?

Thanks

~Tim

0 Kudos
Reply
1,976 Views
Martin_
NXP Employee
NXP Employee
0 Kudos
Reply
1,976 Views
Tim562
Senior Contributor I

Hi martin,

    I was able to get the new httpd server working with MQX 8.3.1.1 on an existing project but have discovered a problem that I thought you and others might want to know about.

    My project makes use of the http POST command to send a binary file from the web client back to my application (it's used to update the application firmware image). This has worked reliably for several legacy projects (including this one) using several older revisions of MQX. Once I installed this latest version of the httpd server this process stopped working. My CGI receive function is called properly as the data arrives and the session->request.content_len value shows the proper data length but my calls to httpd_read() stop short of transferring all incoming data to my temp receive buffer (about 740 bytes short actually). httpd_read() just keeps returning without receiving any data. I restored MQX back to stock revision3.8.1.1 and this process now works properly again. To ensure all data is received before starting to process it, I essentially continue to call http_read() in a while loop until I've read all the data bytes that session->request.content_len indicated were available into a temp receive buffer then I work out of that temp receive buffer. The files I'm transferring are around 900KB in size (some are far larger).

     I don't know if you or anyone has had a chance to evaluate this feature of the new httpd server yet but I would be interested to know if anyone has. Also, if I should be doing this differently with the new server, feel free to make a suggestion. By the way, I have found this new server to provide much better performance then the old one so I would sure love to use it, but this needs to work. Thanks to all !

Best Regards,

Tim Hutchinson


0 Kudos
Reply
1,976 Views
Tim562
Senior Contributor I

My Apologies Martin, Just needed to recompile all libraries (not just RTCS) for the changes made to user_config.h to take effect. Thanks!

~Tim

0 Kudos
Reply
1,976 Views
Tim562
Senior Contributor I

Hi Martin,

     Thanks for the tip. I made the additional changes specified in the post you pointed me to and that cleared up the  "#include partition.h" problem but now I get several problems in the httpd.c file and the httpd_task.c file when attempting to compile the RTCS. These problems all seem to be related to declaring variables of type "sockaddr". I did add the " #define sockaddr  sockaddr_in " line in "Freescale MQX 3.8.1.1\config\twrmpc5125\user_config.h" line as specified. Any ideas? Thanks again for your help.

Best Tim


0 Kudos
Reply
1,976 Views
Tim562
Senior Contributor I

Hi Karel,

     I've been having similar problems with the HTTPD server in MQX 3.8.0 and am wondering if the new server you included in the zip file is compatible with that MQX release? I'm developing with the MPC-5125 so it looks like 3.8.1 will be as far as I would be able to go (I believe there's no support for the 5125 in MQX 4.0). Thanks for your post.

Best

Tim

0 Kudos
Reply
1,976 Views
nicholasgw
Contributor I

Might be a tad late replying, but I was wondering what the implications on ASP scripts are for this new server. Trying to upgrade to it to see if it solves some similar issues, and I can't seem to find anything similar to registering a callback table so that tags like <% asp_fn %> are recognized. Could you recommend the best way to execute ASP scripts using this new server?

Thanks,

Nick

EDIT


Just found the params.cgi_lnk_tbl in the example project before httpd_init() is called. Attempted a similar approach by declaring a fn_lnk_tbl, and using params.fn_lnk_tbl = (HTTPD_FN_LNK_STRUCT*) fn_lnk_tbl.

However, trying to execute the ASP scripts doesn't work still (the web page just displays <% asp_fn %> as text and complains that the <% tag is unclosed. Anything obvious that I'm doing incorrectly? fn_lnk_tbl and it's mapped functions are defined in the same file as those for the cgi map, and those seem to execute fine.

0 Kudos
Reply
1,976 Views
brianr
Contributor I

Thank you.  This is much improved.

0 Kudos
Reply