Re: [paho-dev] Simultaneous sub/pub-instances
a single instance of the client can act as both publisher and subscriber; you do not need to separate them.
I haven't touched the c client for a while, so can't point you at anything more specific, but hopefully that will point you in the right direction.
On 15 Aug 2014 22:16, "Daniel Rasmussen" <Daniel.Rasmussen@xxxxxxxxx
Hi Paho team,
Thank you for a great MQTT library! I’m using the
In a project connecting existing devices to the Internet, I want a service (on the Internet) to be able to receive messages from devices, but the device must also be able to publish messages to the service. This means
that the device needs to run both a publisher and a subscriber instance.
I’ve tried with the async API, running the two instances in two separate threads (eCos). It first seem very well, connecting success and subscribing and I’m able both send and receive message through a mosquito broker.
But sadly I’ve found that the API isn’t thread safe. The socket.c module holds a list of sockets (think is called
s), but this list is static and not protected so the list may be updated from one instance/thread while one other is accessing it.- A race condition causing the a zero pointer to be accessed.
Am I abusing the library by threading two instances in simultaneously or am I just doing it wrong? I guess I could transfer to the sync API, but I thought that the async API will perform better yield-wise.
Thanks in advance.
Software developer, Prevas A/S
8200 Aarhus N, Denmark
Mobile: +45 40 29 24 87
Switchboard: +45 33 15 90 90
paho-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit