CYW943907AEVAL1F HTTP_SERVER_SENT_EVENTS Crashes/Reboots When Client Web Page Goes Away

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ChMa_3922746
Level 5
Level 5
10 likes received 10 likes given 5 likes given

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!

0 Likes
1 Solution
RaktimR_11
Moderator
Moderator
Moderator
500 replies posted 250 replies posted 100 replies posted

Thanks for pointing out this issue. I will raise this feature addition request internally to make wiced_http_response_stream_write robust against client page closure.

View solution in original post

3 Replies
RaktimR_11
Moderator
Moderator
Moderator
500 replies posted 250 replies posted 100 replies posted

Thanks for pointing out this issue. I will raise this feature addition request internally to make wiced_http_response_stream_write robust against client page closure.

Is it possible to say if this has made it into the dev plan (>1 yr old, now)?

0 Likes