cl-mqtt
cl-mqtt copied to clipboard
Unable to put MQTT client into a subsidiary thread
I have some code that successfully subscribes to an MQTT broker, and that logs messages to the screen, using as:start-event-loop.
But since this takes over everything, I wanted to run the event loop in a secondary thread. I put the call to as:start-event-loop into a call to bordeaux-threads:make-thread. But now, when I try to run that code, I get a constant stream of warning messages like this:
WARNING:
MQTT error: Timed out writing message: #S(CL-MQTT::MQTT-MESSAGE
:FIXED-HEADER 192
:PROTOCOL-NAME ""
:PROTOCOL-LEVEL 0
:CONNECT-FLAGS 0
:CONNECT-KEEPALIVE 0
:RET-CODE-RAW 0
:CLIENT-ID ""
:MID 0
:TOPIC ""
:WILL-TOPIC ""
:WILL-MESSAGE ""
:USERNAME ""
:PASSWORD ""
:PAYLOAD #()
:SUBSCRIPTION-QOS-RAW 0)
and no logging messages are ever printed. My understanding is that it should be possible to run the cl-async event loop in a thread. I don't understand what it is about an MQTT client that would make running in a thread different from running in the main process. It seems that somehow a timeout is being triggered, but the client code does not set a timeout anywhere.