Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect to mosquitto broker #6

Open
VaclavSynacek opened this issue Nov 8, 2019 · 0 comments
Open

Cannot connect to mosquitto broker #6

VaclavSynacek opened this issue Nov 8, 2019 · 0 comments

Comments

@VaclavSynacek
Copy link

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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant