执行mosquitto_loop_forever时,返回错误值8。
查看相应的头文件

MOSQ_ERR_SUCCESS = 0,
MOSQ_ERR_NOMEM = 1,
MOSQ_ERR_PROTOCOL = 2,
MOSQ_ERR_INVAL = 3,
MOSQ_ERR_NO_CONN = 4,
MOSQ_ERR_CONN_REFUSED = 5,
MOSQ_ERR_NOT_FOUND = 6,
MOSQ_ERR_CONN_LOST = 7,
MOSQ_ERR_TLS = 8,

错误号8为TLS相关的错误。

使用mosquitto_pub测试,提示如下错误:

Client const.net.cn sending CONNECT
OpenSSL Error[0]: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
Error: A TLS error occurred.

证书应该是合法的,问题可能出在时间上。

date

Fri Dec 6 08:59:02 CST 2019

ntpdate time.apple.com

29 Jul 12:02:53 ntpdate[26987]: step time server 17.253.84.123 offset +51937409.969086 sec

date

Thu Jul 29 12:03:06 CST 2021

再执行mosquitto_pub就正常了。

Client const.net.cn sending CONNECT
Client const.net.cn received CONNACK (0)
Client const.net.cn sending PUBLISH (d0, q2, r0, m1, 'command///req/reqid-7', ... (29 bytes))
Client const.net.cn received PUBREC (Mid: 1)
Client const.net.cn sending PUBREL (m1)
Client const.net.cn received PUBCOMP (Mid: 1, RC:0)
Client const.net.cn sending DISCONNECT
本文链接地址:https://const.net.cn/251.html

标签: mqtt

添加新评论