Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[mosquitto-dev] websocket issues

Hi all,
    I'm using the mosquitto server version 1.4.0 with websocket, and the config use_username_as_clientid is true.I found when two web clients using the same username, the mosquitto server can't disconnect the old one,and all the web client  Unable to receive data from server.

   I modified function "void do_disconnect(struct mosquitto_db *db, struct mosquitto *context)" in "loop.c" like this:
....................................
            mosquitto__add_context_to_disused(db, context);
            if(context->id){
                HASH_DELETE(hh_id, db->contexts_by_id, context);
                _mosquitto_free(context->id);
                context->id = NULL;
            }
        }
#ifdef WITH_WEBSOCKETS
    }
#endif
    context->state = mosq_cs_disconnected;
}


To:
....................................
            mosquitto__add_context_to_disused(db, context);
            if(context->id){
                HASH_DELETE(hh_id, db->contexts_by_id, context);
                _mosquitto_free(context->id);
                context->id = NULL;
            }
        }
        context->state = mosq_cs_disconnected;
#ifdef WITH_WEBSOCKETS
    }
#endif
}

then it worked.

I thinke context->state with websocket should be changed in the function "callback_mqtt" in "websocket.c",Is this correct?

Thanks for your time.

 

Regards,
FeelyChau

Back to the top