Code Monkey home page Code Monkey logo

cl-mqtt's People

Contributors

ivan4th avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

tobbelobb lisp

cl-mqtt's Issues

client terminates a connection shortly after publishing a message

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 branch
  • mosquitto mqtt server

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.

Cannot connect to mosquitto broker

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:

  • sbcl 1.5.8.debian, mosquitto 1.6.7-1, Linux 5.2.0-3 amd64
  • sbcl 1.3.7.debian, mosquitto 1.4.10, Linux 4.19.66 armv6l

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))

SSL cert

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...

Auth wanted

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.