Skip to main content

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

Hi FeelyChau,

Sorry for the delay in replying, I took a break from this sort of
thing over Christmas/New Year.

I think what you've spotted is quite correct. For websockets clients,
do_disconnect() sets the state to mosq_cs_disconnect_ws and then
incorrectly resets it to mosq_cs_disconnected later on. The only fix
is to do what you suggest.

There is no requirement for the state member to be set in
websockets.c, it can be changed as is being done in loop.c for
websockets clients.

Thanks for spotting this and reporting it, I've pushed a fix to the 1.4 branch.

Cheers,

Roger


On Fri, Dec 19, 2014 at 9:03 AM, 周飞宇 <feely@xxxxxxxxxxx> wrote:
> 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
>
> _______________________________________________
> mosquitto-dev mailing list
> mosquitto-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from
> this list, visit
> https://dev.eclipse.org/mailman/listinfo/mosquitto-dev


Back to the top