Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mosquitto-dev] does calling mosquitto_subscribe twice add a new subscription or replace the existing one?

This shouldn't be an issue. You can subscribe to more than one topic on a single connection.  Not sure if there's a subscription limit per connection... I've done 10's of subscriptions on a single connection just fine. 



> On May 29, 2017, at 7:39 PM, Steve Prior <sprior@xxxxxxxxxxxx> wrote:
> 
> I'm getting started using the mqtt pack for SWI-Prolog to subscribe to topics on a mosquitto message broker.  The library under the covers uses the c mosquitto API.
> 
> I've been able to subscribe to a topic and process incoming messages in Prolog - this is working.  What I'm trying to understand is whether I can subscribe to two completely different topics using the same mqtt connection.  I was under the impression that this was possible, but what I think I saw was than when I called subscribe a second time I started seeing the messages under the new topic, but no longer saw the messages I had previously subscribed to.  Then when I called subscribe again with the original topic I saw only those and not the ones for the second topic.
> 
> I've gone through the prolog -> mosquitto interface code and the interface code is doing very little beyond retrieving the connection and passing the call to the mosquitto c API, so I don't think that interface is adding any new restrictions.
> 
> Looking at the c API documentation for mosquitto_subscribe it does not specify the behavior if it is called twice.  Can anyone clarify if the new subscription topic is supposed to replace (or add) to any previous subscribed topics?
> 
> Thanks
> Steve Prior
> 
> _______________________________________________
> 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