3 Replies Latest reply on Jan 10, 2020 9:10 AM by ChMa_3922746

    CYW943907AEVAL1F HTTP_SERVER_SENT_EVENTS Crashes/Reboots When Client Web Page Goes Away

    ChMa_3922746

      I would like to make use of server side events (SSE), and have compiled/run the example on a CYW943907AEVAL1F eval board: snip/http_server_sent_events

       

      (Side note: I can get it to run reliably once I comment out the line "wiced_rtos_delay_milliseconds(300 * (unsigned int)random_initial);" in sntp.c.  -- Minor issue).

       

      Now, I can see the time updates being sent to the browser page and it all appears to work well:

      This webpage demonstrates how a webserver notifies its clients using Server-Sent Event (SSE).

      2018-12-29T18:06:38.388000Z

      2018-12-29T18:06:39.388000Z

      2018-12-29T18:06:40.388000Z

      2018-12-29T18:06:41.388000Z

      ...etc

       

      However, when I close the browser page, then the server crashes and reboots.  Apparently it is crashing in the function wiced_http_response_stream_write in the function wiced_result_t send_event:

       

      static wiced_result_t send_event( void* arg )

      {

          wiced_iso8601_time_t current_time;

          char time_string[28];

          wiced_result_t result;

       

          UNUSED_PARAMETER( arg );

       

          if ( http_event_stream == NULL )

          {

              WPRINT_APP_INFO( ( "No stream!\n" ) );

              return WICED_ERROR;

          } else {

              WPRINT_APP_INFO( ( "Event stream is present...good!\n" ) );

          }

       

          /* SSE is prefixed with "data: " */

          result =  wiced_http_response_stream_write( http_event_stream, (const void*)EVENT_STREAM_DATA, sizeof( EVENT_STREAM_DATA ) - 1 ); <- it croaks here

      ...

      }

       

      The console output is:

      Event stream is present...good!

      ...the web page is closed, then the processor croaks and reboots...

      Starting WICED vWiced_006.002.001.0002

      Platform CYW943907AEVAL1F initialised

      Started ThreadX v5.8

      Initialising NetX_Duo v5.10_sp3

      Creating Packet pools

      ...etc

       

      I think the function wiced_http_response_stream_write should be robust against client page closure.  For some reason it isn't happy.  I am wondering if anyone has seen this behaviour, and if so, what their solution might have been?

       

      Thanks!