我已经为MQTT通信建立了一个莫斯基托经纪人,但我甚至无法让它正常工作。在连接和等待比特之后,服务器重置客户端连接并显示'Socket error on client .. , disconnecting.'。
我已经排除了客户端的错误,因为在使用两个不同的客户端软件(MQTT.fx和mqtt-间谍)时,错误仍然存在。
Connection-timeout: 30
Keep-alive interval: 30摩斯基托运行在最新版本(蚊子版本1.4.2)和股票配置。
我执行下列操作:
编辑:
运行代码
static void loop_handle_reads_writes(struct mosquitto_db *db, struct pollfd *pollfds)
{
[...]
if(pollfds[context->pollfd_index].revents & POLLIN){
if(_mosquitto_packet_read(db, context)){
do_disconnect(db, context); <-- Line that causes disconnection
continue;
}
}
}
[...]
void do_disconnect(struct mosquitto_db *db, struct mosquitto *context)
{
char *id;
if(context->state == mosq_cs_disconnected){
return;
}
[...]
{
if(db->config->connection_messages == true){
if(context->id){
id = context->id;
}else{
id = "<unknown>";
}
if(context->state != mosq_cs_disconnecting){
_mosquitto_log_printf(NULL, MOSQ_LOG_NOTICE, "Socket error on client %s, disconnecting.", id);
}else{
_mosquitto_log_printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected.", id);
}
}
mqtt3_context_disconnect(db, context);
[...]
if(context->clean_session){
mosquitto__add_context_to_disused(db, context);
if(context->id){
HASH_DELETE(hh_id, db->contexts_by_id, context);
_mosquitto_free(context->id);
context->id = NULL;
}
}
context->state = mosq_cs_disconnected;
}
}控制台日志:
1433171947: New connection from 192.168.2.5 on port 1883.
1433171947: New client connected from 192.168.2.5 as testuser (c1, k30, u'testuser').
1433171947: Sending CONNACK to testuser (0, 0)
1433171954: Received PUBLISH from testuser (d0, q1, r1, m1, 'test', ... (4 bytes))
1433171954: Sending PUBACK to testuser (Mid: 1)
1433171984: Received PINGREQ from testuser
1433171984: Sending PINGRESP to testuser
1433172003: Socket error on client testuser, disconnecting.以下是交换的13帧的一些数据包捕获和导致套接字错误的连接重置。
服务器(192.168.2.15)捕获记录:
No. Time Source Destination Protocol Length Info
129 14.587072000 192.168.2.5 192.168.2.15 TCP 62 55176 > ibm-mqisdp [SYN] Seq=0 Win=8192 Len=0 MSS=1460 SACK_PERM=1
Frame 129: 62 bytes on wire (496 bits), 62 bytes captured (496 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: ibm-mqisdp (1883), Seq: 0, Len: 0
No. Time Source Destination Protocol Length Info
131 14.587250000 192.168.2.5 192.168.2.15 TCP 60 55176 > ibm-mqisdp [ACK] Seq=1 Ack=1 Win=17424 Len=0
Frame 131: 60 bytes on wire (480 bits), 60 bytes captured (480 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: ibm-mqisdp (1883), Seq: 1, Ack: 1, Len: 0
No. Time Source Destination Protocol Length Info
132 14.589586000 192.168.2.5 192.168.2.15 TCP 92 55176 > ibm-mqisdp [PSH, ACK] Seq=1 Ack=1 Win=17424 Len=38
Frame 132: 92 bytes on wire (736 bits), 92 bytes captured (736 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: ibm-mqisdp (1883), Seq: 1, Ack: 1, Len: 38
Data (38 bytes)
0000 10 24 00 04 4d 51 54 54 04 c2 00 1e 00 08 74 65 .$..MQTT......te
0010 73 74 75 73 65 72 00 08 74 65 73 74 75 73 65 72 stuser..testuser
0020 00 04 6d 61 72 79 ..mary
No. Time Source Destination Protocol Length Info
135 14.590183000 192.168.2.5 192.168.2.15 TCP 60 55176 > ibm-mqisdp [ACK] Seq=39 Ack=5 Win=17420 Len=0
Frame 135: 60 bytes on wire (480 bits), 60 bytes captured (480 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: ibm-mqisdp (1883), Seq: 39, Ack: 5, Len: 0
No. Time Source Destination Protocol Length Info
144 21.534467000 192.168.2.5 192.168.2.15 TCP 68 55176 > ibm-mqisdp [PSH, ACK] Seq=39 Ack=5 Win=17420 Len=14
Frame 144: 68 bytes on wire (544 bits), 68 bytes captured (544 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: ibm-mqisdp (1883), Seq: 39, Ack: 5, Len: 14
Data (14 bytes)
0000 33 0c 00 04 74 65 73 74 00 01 74 65 73 74 3...test..test
No. Time Source Destination Protocol Length Info
146 21.534941000 192.168.2.5 192.168.2.15 TCP 60 55176 > ibm-mqisdp [ACK] Seq=53 Ack=9 Win=17416 Len=0
Frame 146: 60 bytes on wire (480 bits), 60 bytes captured (480 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: ibm-mqisdp (1883), Seq: 53, Ack: 9, Len: 0
No. Time Source Destination Protocol Length Info
184 51.556401000 192.168.2.5 192.168.2.15 TCP 60 55176 > ibm-mqisdp [PSH, ACK] Seq=53 Ack=9 Win=17416 Len=2
Frame 184: 60 bytes on wire (480 bits), 60 bytes captured (480 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: ibm-mqisdp (1883), Seq: 53, Ack: 9, Len: 2
Data (2 bytes)
0000 c0 00 ..
No. Time Source Destination Protocol Length Info
187 51.850874000 192.168.2.5 192.168.2.15 TCP 60 [TCP Retransmission] 55176 > ibm-mqisdp [PSH, ACK] Seq=53 Ack=9 Win=17416 Len=2
Frame 187: 60 bytes on wire (480 bits), 60 bytes captured (480 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: ibm-mqisdp (1883), Seq: 53, Ack: 9, Len: 2
Data (2 bytes)
0000 c0 00 ..
No. Time Source Destination Protocol Length Info
190 52.452535000 192.168.2.5 192.168.2.15 TCP 60 [TCP Retransmission] 55176 > ibm-mqisdp [PSH, ACK] Seq=53 Ack=9 Win=17416 Len=2
Frame 190: 60 bytes on wire (480 bits), 60 bytes captured (480 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: ibm-mqisdp (1883), Seq: 53, Ack: 9, Len: 2
Data (2 bytes)
0000 c0 00 ..
No. Time Source Destination Protocol Length Info
197 53.655674000 192.168.2.5 192.168.2.15 TCP 60 [TCP Retransmission] 55176 > ibm-mqisdp [PSH, ACK] Seq=53 Ack=9 Win=17416 Len=2
Frame 197: 60 bytes on wire (480 bits), 60 bytes captured (480 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: ibm-mqisdp (1883), Seq: 53, Ack: 9, Len: 2
Data (2 bytes)
0000 c0 00 ..
No. Time Source Destination Protocol Length Info
201 56.056945000 192.168.2.5 192.168.2.15 TCP 60 [TCP Retransmission] 55176 > ibm-mqisdp [PSH, ACK] Seq=53 Ack=9 Win=17416 Len=2
Frame 201: 60 bytes on wire (480 bits), 60 bytes captured (480 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: ibm-mqisdp (1883), Seq: 53, Ack: 9, Len: 2
Data (2 bytes)
0000 c0 00 ..
No. Time Source Destination Protocol Length Info
213 60.854141000 192.168.2.5 192.168.2.15 TCP 60 [TCP Retransmission] 55176 > ibm-mqisdp [PSH, ACK] Seq=53 Ack=9 Win=17416 Len=2
Frame 213: 60 bytes on wire (480 bits), 60 bytes captured (480 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: ibm-mqisdp (1883), Seq: 53, Ack: 9, Len: 2
Data (2 bytes)
0000 c0 00 ..
No. Time Source Destination Protocol Length Info
233 70.449632000 192.168.2.5 192.168.2.15 TCP 60 55176 > ibm-mqisdp [RST, ACK] Seq=55 Ack=9 Win=0 Len=0
Frame 233: 60 bytes on wire (480 bits), 60 bytes captured (480 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: ibm-mqisdp (1883), Seq: 55, Ack: 9, Len: 0客户端(192.168.2.5)捕获记录:
No. Time Source Destination Protocol Length Info
174 5.754193000 192.168.2.5 192.168.2.15 TCP 62 55176→1883 [SYN] Seq=0 Win=8192 Len=0 MSS=1460 SACK_PERM=1
Frame 174: 62 bytes on wire (496 bits), 62 bytes captured (496 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: 1883 (1883), Seq: 0, Len: 0
No. Time Source Destination Protocol Length Info
176 5.754376000 192.168.2.5 192.168.2.15 TCP 54 55176→1883 [ACK] Seq=1 Ack=1 Win=17424 Len=0
Frame 176: 54 bytes on wire (432 bits), 54 bytes captured (432 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: 1883 (1883), Seq: 1, Ack: 1, Len: 0
No. Time Source Destination Protocol Length Info
177 5.756658000 192.168.2.5 192.168.2.15 TCP 92 55176→1883 [PSH, ACK] Seq=1 Ack=1 Win=17424 Len=38
Frame 177: 92 bytes on wire (736 bits), 92 bytes captured (736 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: 1883 (1883), Seq: 1, Ack: 1, Len: 38
Data (38 bytes)
0000 10 24 00 04 4d 51 54 54 04 c2 00 1e 00 08 74 65 .$..MQTT......te
0010 73 74 75 73 65 72 00 08 74 65 73 74 75 73 65 72 stuser..testuser
0020 00 04 6d 61 72 79 ..mary
No. Time Source Destination Protocol Length Info
180 5.757101000 192.168.2.5 192.168.2.15 TCP 54 55176→1883 [ACK] Seq=39 Ack=5 Win=17420 Len=0
Frame 180: 54 bytes on wire (432 bits), 54 bytes captured (432 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: 1883 (1883), Seq: 39, Ack: 5, Len: 0
No. Time Source Destination Protocol Length Info
393 12.701517000 192.168.2.5 192.168.2.15 TCP 68 55176→1883 [PSH, ACK] Seq=39 Ack=5 Win=17420 Len=14
Frame 393: 68 bytes on wire (544 bits), 68 bytes captured (544 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: 1883 (1883), Seq: 39, Ack: 5, Len: 14
Data (14 bytes)
0000 33 0c 00 04 74 65 73 74 00 01 74 65 73 74 3...test..test
No. Time Source Destination Protocol Length Info
395 12.701938000 192.168.2.5 192.168.2.15 TCP 54 55176→1883 [ACK] Seq=53 Ack=9 Win=17416 Len=0
Frame 395: 54 bytes on wire (432 bits), 54 bytes captured (432 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: 1883 (1883), Seq: 53, Ack: 9, Len: 0
No. Time Source Destination Protocol Length Info
1192 42.723471000 192.168.2.5 192.168.2.15 TCP 56 55176→1883 [PSH, ACK] Seq=53 Ack=9 Win=17416 Len=2
Frame 1192: 56 bytes on wire (448 bits), 56 bytes captured (448 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: 1883 (1883), Seq: 53, Ack: 9, Len: 2
Data (2 bytes)
0000 c0 00 ..
No. Time Source Destination Protocol Length Info
1205 43.017917000 192.168.2.5 192.168.2.15 TCP 56 [TCP Retransmission] 55176→1883 [PSH, ACK] Seq=53 Ack=9 Win=17416 Len=2
Frame 1205: 56 bytes on wire (448 bits), 56 bytes captured (448 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: 1883 (1883), Seq: 53, Ack: 9, Len: 2
Data (2 bytes)
0000 c0 00 ..
No. Time Source Destination Protocol Length Info
1213 43.619506000 192.168.2.5 192.168.2.15 TCP 56 [TCP Retransmission] 55176→1883 [PSH, ACK] Seq=53 Ack=9 Win=17416 Len=2
Frame 1213: 56 bytes on wire (448 bits), 56 bytes captured (448 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: 1883 (1883), Seq: 53, Ack: 9, Len: 2
Data (2 bytes)
0000 c0 00 ..
No. Time Source Destination Protocol Length Info
1236 44.822621000 192.168.2.5 192.168.2.15 TCP 56 [TCP Retransmission] 55176→1883 [PSH, ACK] Seq=53 Ack=9 Win=17416 Len=2
Frame 1236: 56 bytes on wire (448 bits), 56 bytes captured (448 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: 1883 (1883), Seq: 53, Ack: 9, Len: 2
Data (2 bytes)
0000 c0 00 ..
No. Time Source Destination Protocol Length Info
1273 47.224018000 192.168.2.5 192.168.2.15 TCP 56 [TCP Retransmission] 55176→1883 [PSH, ACK] Seq=53 Ack=9 Win=17416 Len=2
Frame 1273: 56 bytes on wire (448 bits), 56 bytes captured (448 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: 1883 (1883), Seq: 53, Ack: 9, Len: 2
Data (2 bytes)
0000 c0 00 ..
No. Time Source Destination Protocol Length Info
1462 52.021241000 192.168.2.5 192.168.2.15 TCP 56 [TCP Retransmission] 55176→1883 [PSH, ACK] Seq=53 Ack=9 Win=17416 Len=2
Frame 1462: 56 bytes on wire (448 bits), 56 bytes captured (448 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: 1883 (1883), Seq: 53, Ack: 9, Len: 2
Data (2 bytes)
0000 c0 00 ..
No. Time Source Destination Protocol Length Info
1713 61.616726000 192.168.2.5 192.168.2.15 TCP 54 55176→1883 [RST, ACK] Seq=55 Ack=9 Win=0 Len=0
Frame 1713: 54 bytes on wire (432 bits), 54 bytes captured (432 bits) on interface 0
Ethernet II, Src: Cisco-Li_21:62:a7 (00:1e:e5:21:62:a7), Dst: NX_6a:d6:31 (00:0c:29:6a:d6:31)
Internet Protocol Version 4, Src: 192.168.2.5 (192.168.2.5), Dst: 192.168.2.15 (192.168.2.15)
Transmission Control Protocol, Src Port: 55176 (55176), Dst Port: 1883 (1883), Seq: 55, Ack: 9, Len: 0发布于 2015-06-02 12:13:08
_mosquitto_packet_read()失败的最可能原因是远程端关闭了连接,因此无法读取。如果do_disconnect()达到了您提到的目的,那么从代理的角度来看,套接字基本上仍然是开放的。
我刚刚尝试使用下面的客户端代码来重现这个问题(您需要安装Paho Python,pip install paho-mqtt)。
import paho.mqtt.client as paho
mqtt = paho.Client(client_id="testuser", clean_session=True)
mqtt.username_pw_set("testuser", "password")
mqtt.connect("localhost", 1883, 30)
mqtt.publish("test", "test", qos=1, retain=True)
mqtt.loop_forever()我从经纪人那里得到的日志是:
1433245884: New connection from ::1 on port 1883.
1433245884: New client connected from ::1 as testuser (c1, k30, u'testuser').
1433245884: Sending CONNACK to testuser (0, 0)
1433245884: Received PUBLISH from testuser (d0, q1, r1, m1, 'test', ... (4 bytes))
1433245884: Sending PUBACK to testuser (Mid: 1)
1433245915: Received PINGREQ from testuser
1433245915: Sending PINGRESP to testuser
1433245945: Received PINGREQ from testuser
1433245945: Sending PINGRESP to testuser
1433245975: Received PINGREQ from testuser
1433245975: Sending PINGRESP to testuser
...你能在你的系统上试试这个来比较一下吗?
发布于 2018-08-10 11:12:07
我们正面临这一错误时,桥的配置是从蚊子到EMQ经纪人。我们有两座桥,其中一座在QoS 0上,过去运行良好。QoS 2上的那个有问题。以下是可以帮助你的意见和步骤:
使蚊虫能够完全伐木
这是通过在log_type all配置中设置属性来实现的。查找/var/log/mosquitto/mosquitto.log或'/var/log/messages`‘上的错误,这取决于您的Linux发行版。
我们发现的
摩斯基托有需要发布到EMQ的消息排队,EMQ也有消息要发布给蚊子。一旦建立了连接,代理就忙于发送数据包,而蚊虫过去常常错过keepalive_interval配置时发送的keepalive_interval。
在使用命令sudo emqttd_ctl listeners检查客户端终止的EMQ原因时,可以发现超时是问题所在。因此,我们使用mqtt.client.idle_timeout增加了EMQ上的超时。
这一问题已定在第二天再次发生。当检查EMQ上的日志时,超时是终止的原因,并且在指定的时间内没有从蚊子发送PINGREQ。我们怀疑带宽,并在一段时间内推送许多大小良好的消息,这被怀疑是终止的原因。我们决定通过将信息计数设置为1来设置蚊虫和EMQ一次发送一条消息。这使得连接稳定,消息被传递。
一种建议是,如果在retry_interval 1或2上发送大量消息,则增加QoS上的QoS和EMQ上的mqtt.session.retry_interval。另外,在这种情况下,QoS上的mqtt.session.await_rel_timeout是一个重要的配置。mqtt.client.max_publish_rate是另一个需要研究的问题。
https://stackoverflow.com/questions/30577542
复制相似问题