客户端上的 MQTT 套接字错误 <unknown> [英] MQTT Socket error on client <unknown>

查看:111
本文介绍了客户端上的 MQTT 套接字错误 <unknown>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已在 Raspberry Pi 上设置了 MQTT 并为代理配置了 Arduino Uno,但我在/var/log/mosquitto/mosquitto.log 文件中看到以下条目:

I have setup MQTT on a Raspberry Pi and configured an Arduino Uno to the broker, but I am seeing the following entry in the /var/log/mosquitto/mosquitto.log file:

New connection from 192.168.10.114 on port 1883.
Socket error on client <unknown>, disconnecting.

Pi 设置了 ETH0 连接到我的本地 LAN,IP 地址为 192.168.1.50

The Pi is setup with ETH0 wired to my local LAN and has an IP address of 192.168.1.50

Pi 上还有一个 WiFi AP 设置.Arduino Uno 通过 WiFi 连接以发送/接收 MQTT 消息.WiFi AP 的 IP 地址为 192.168.10.1,并通过 dnsmasq 提供 DHCP 租用.

There is also a WiFi AP setup on the Pi. The Arduino Uno connects via WiFi to send/receive MQTT messages. The WiFi AP has an IP address of 192.168.10.1 and provides DHCP leases via dnsmasq.

我尝试在本地 MQTT 代理服务器(Pi)上发布和订阅测试并得到相同的错误:

I have tried publishing and subscribing test on the local MQTT broker server (the Pi) and get the same error:

Command:
mosquitto_sub -h 192.168.10.1 -t topic

mosquitto.log:
New connection from 192.168.10.1 on port 1883.
New client connected from 192.168.10.1 as mosqsub/1837-raspberryp (cl, k60).
Socket error on client <unknown>, disconnecting.

这里是/etc/mosquitto/mosquitto.conf:

Here is /etc/mosquitto/mosquitto.conf:

pid_file /var/run/mosquitto.pid

persistence true
log_dest file /var/log/mosquitto/mosquitto.log

allow_anonymous true

include_dir /etc/mosquitto/conf.d

sudo service mosquitto stop须藤服务蚊子开始:

sudo service mosquitto stop sudo service mosquitto start:

mosquitto version 1.4.8 terminating
mosquitto version 1.4.8 (build date Sun, 14 Feb 2016 15:06:55 +0000) starting
Config loaded from /etc/mosquitto/mosquitto.conf.
Opening ipv4 listen socket on port 1883.
Opening ipv6 listen socket on port 1883.

我的接口配置可能有问题.这是/etc/network/interfaces:

There might be an issue in my interfaces configuration. Here is /etc/network/interfaces:

source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
    address 192.168.10.1
    netmask 255.255.255.0

谁能指出 MQTT 上套接字错误的来源?

Can anyone point me on where the socket error is coming from on MQTT?

推荐答案

我来到这个帖子是因为我遇到了同样的错误.经过更多的故障排除后,它与身份验证配置有关 - 客户端(Arduino)试图匿名连接(没有密码),而代理(Pi)被设置为只允许经过身份验证的连接(MQTT配置中的allow_anonymous false).

I came to this thread because I was facing the same error. After some more troubleshooting, it was related to the authentication configuration - the client (Arduino) was trying to connect anonymously (with no password), while the broker (Pi) was set up to only allow authenticated connections (allow_anonymous false in the MQTT configuration).

向 Arduino 连接代码添加正确的密码为我解决了这个问题.

Adding the correct password to the Arduino connection code solved the issue for me.

这篇关于客户端上的 MQTT 套接字错误 &lt;unknown&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆