ivan4th / cl-mqtt Goto Github PK
View Code? Open in Web Editor NEWMQTT driver for cl-async
License: MIT License
MQTT driver for cl-async
License: MIT License
I'm seeing strange behaviour: shortly after publishing a message, client dies with connection timed out (waiting for :PINGRESP)
.
My code is very similar to the example provided in READE.md, with one difference -- I call mqtt:publish
from a thread (via bordeaux-threads
). If I setup the code to just listen for a connection (in an event loop), I can consume messages and in mosquitto
log I see messages like:
1515795903: Received PINGREQ from cl-mqtt
1515795903: Sending PINGRESP to cl-mqtt
But shortly after I publish anything, I get:
connection timed out (waiting for :PINGRESP)
and server logs:
1515795988: Socket error on client cl-mqtt, disconnecting.
I counted PINGREQ
/PINGRESP
in the server's log file and I do not see any un-answered requests. It seems cl-mqtt
never sends PINGREQ
but expectes PINGRESP
. Any ideas?
my setup:
cl-mqtt
, master branchmosquitto
mqtt serverI 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.
Hello,
this might be my basic misunderstanding, but I am unable to use this library to connect to mosquitto mqtt broker.
On the client side I get:
WARNING: MQTT error: connection timed out (waiting for :CONNACK)
On mosquitto side I get:
1573232854: New connection from 127.0.0.1 on port 1883.
1573232861: Socket error on client <unknown>, disconnecting.
So cl-mqtt is somehow reaching the broker, but the handshake is not completed.
Tested with cl-mqtt a7028bc on 2 different machines:
with only slightly modified example form README (I am not using swank, so no cl-async-repl):
(ql:quickload :cl-async)
(ql:quickload :cl-mqtt)
(defpackage :mqtt-player
(:use :cl :mqtt :bb))
(in-package :mqtt-player)
(defun test-it (host port)
(bb:alet ((conn (mqtt:connect
host
:port port
:client-id "mqtt-player"
:on-message #'(lambda (message)
(format t "~%RECEIVED: ~s~%"
(babel:octets-to-string
(mqtt:mqtt-message-payload message)
:encoding :utf-8))))))
(bb:walk
(mqtt:subscribe conn "/a/#")
(mqtt:subscribe conn "/b/#")
(mqtt:publish conn "/a/b" "whatever1")
(mqtt:unsubscribe conn "/a/#")
(mqtt:publish conn "/a/b" "whatever2")
(mqtt:publish conn "/b/c" "foobar")
(as:with-delay (1)
(mqtt:disconnect conn))))
(values))
(as:with-event-loop ()
(test-it "localhost" 1883))
Hi ivan4th!
I'm trying to connect to a broker running on AWS via SSL.
I'm following this guide and have cert and key ready.
I don't know much about network programming, but I notice that cert and key are often specified together with host, topic etc. Would this be possible when using cl-mqtt as well?
I've tried to replace tcp-connect with tcp-ssl-connect (from cl-async-ssl) in client.lisp, but I haven't figured out how to specify cert and key files for the connection.
Documentation for cl-async-ssl is here.
My current understanding is that we need to somehow create a "SSL session" that contains cert and key, and then somehow link it into cl-async-ssl:tcp-ssl-connect.
I'd like to add ssl capability to cl-mqtt, but I'm so unfamiliar with cl-async and network programming in general that I'm failing to even debug packet traffic...
How would you go about adding authentication?
Ability to provide a username and a password would solve my usecase, and I'd gladly implement if I knew how.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.