Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

Intermittent crash in using Mongoose library

rajamandavarajamandava Singapore

Hi

I am using Mongoose library as websocket server in c++ library to send messages to remote webpage.
Most of the times it works fine but in some instances my library is crashing when trying to send message.
This usually happens at startup when I try to send message 10 seconds after mongoose websocket server start.

The place where it is being crashed is in for loop in following code. Can you advise root cause and any remedial action?

    //send message using Mongoose
    struct mg_str msg = mg_mk_str(strWebMessage.c_str());
    bool bValidConnection = false;

    //validate the connection in the mongoose connection store.
    struct mg_connection *c;
    for (c = mg_next(mmg_ServerConnection->mgr, NULL); c != NULL; c = mg_next(mmg_ServerConnection->mgr, c)) {
        if (mmg_ClientConnection ==  c)
        {
            bValidConnection = true;
            break;
        }
    }
Sign In or Register to comment.