eclipse / paho.mqtt-sn.embedded-c

Paho C MQTT-SN gateway and libraries for embedded systems. Paho is an Eclipse IoT project.
https://eclipse.org/paho
Other
315 stars 178 forks source link

Error: BrokerRecvTask can't receive a packet from Broker errno=0 Client (Disconnect ACK) #154

Closed jelalanne closed 4 years ago

jelalanne commented 5 years ago

Hi,

I am having some troubles using the Gateway. In fact when I'm using TLS connection, I have this error everytime the gateway receives a message from client and tries to send a disconnect ACK to the client. Then, program continues but next messages are received but not transmitted to the broker. @ty4tw Thanks for helping (again, sorry)

ty4tw commented 5 years ago

Hi,

Pls Attach the log of GW.

jelalanne commented 5 years ago

Here you can see 2 cases: the first message is correctly received, with PUBLISH being received by the broker, but not in second message. Whole thing with this error on disconnect ACK.

`


20190528 113022.587 PahoGateway-01 has been started.

ConfigFile: ./gateway.conf ClientList: ./clients.conf PreDefFile: ./predefinedTopic.conf SensorN/W: Gateway Port: 10000 Broadcast Address: ff32:40:fd5a:b03d:7f78::1 Interface: wpan0 Broker: 192.168.43.218 : 1883, 4321 RootCApath: /home/pi/SSL/ RootCAfile: /home/pi/SSL/ca.crt CertKey: (null) PrivateKey: (null)

20190528 113028.339 CONNECT <--- Client2  0D 04 04 01 00 0A 43 6C 69 65 6E 74 32

20190528 113028.435 CONNECT ===> Client2  10 13 00 04 4D 51 54 54 04 02 00 0A 00 07 43 6C 69 65 6E 74 32

20190528 113028.589 CONNACK <=== Client2  20 02 00 00

20190528 113028.589 CONNACK ---> Client2  03 05 00 unicast sendto fd5a:b03d:7f78:0:efd:4aca:49a9:e0ff%wpan0, port: 44861 length = 3

20190528 113028.641 REGISTER 0001 <--- Client2  1A 0A 00 00 00 01 2F 43 6C 69 65 6E 74 32 2F 74 65 6D 70 65 72 61 74 75 72 65

20190528 113028.641 REGACK 0001 ---> Client2  07 0B 00 01 00 01 00 unicast sendto fd5a:b03d:7f78:0:efd:4aca:49a9:e0ff%wpan0, port: 44861 length = 7

20190528 113028.692 PUBLISH 0002 <--- Client2  91 0C 20 00 01 00 02 7B 22 4D 61 63 68 69 6E 65 22 3A 7B 22 49 64 22 3A 22 43 6C 69 65 6E 74 32 22 2C 22 54 65 6D 70 65 72 61 74 75 72 65 22 3A 35 32 2E 30 37 2C 22 50 72 65 73 73 75 72 65 22 3A 30 7D 2C 22 41 6D 62 69 65 6E 74 22 3A 7B 22 54 65 6D 70 65 72 61 74 75 72 65 22 3A 30 2C 22 48 75 6D 69 64 69 74 79 22 3A 30 7D 2C 22 54 69 6D 65 43 72 65 61 74 65 64 22 3A 22 32 30 31 39 2D 30 31 2D 30 31 54 30 30 3A 30 31 3A 31 39 22 7D

20190528 113028.692 PUBLISH 0002 ===> Client2  32 A2 01 00 14 2F 43 6C 69 65 6E 74 32 2F 74 65 6D 70 65 72 61 74 75 72 65 00 02 7B 22 4D 61 63 68 69 6E 65 22 3A 7B 22 49 64 22 3A 22 43 6C 69 65 6E 74 32 22 2C 22 54 65 6D 70 65 72 61 74 75 72 65 22 3A 35 32 2E 30 37 2C 22 50 72 65 73 73 75 72 65 22 3A 30 7D 2C 22 41 6D 62 69 65 6E 74 22 3A 7B 22 54 65 6D 70 65 72 61 74 75 72 65 22 3A 30 2C 22 48 75 6D 69 64 69 74 79 22 3A 30 7D 2C 22 54 69 6D 65 43 72 65 61 74 65 64 22 3A 22 32 30 31 39 2D 30 31 2D 30 31 54 30 30 3A 30 31 3A 31 39 22 7D

20190528 113028.693 PUBACK 0002 <=== Client2  40 02 00 02 20190528 113028.693 PUBACK 0002 ---> Client2  07 0D 00 01 00 02 00 unicast sendto fd5a:b03d:7f78:0:efd:4aca:49a9:e0ff%wpan0, port: 44861 length = 7 20190528 113028.722 DISCONNECT <--- Client2  02 18

20190528 113028.722 DISCONNECT ---> Client2  02 18 unicast sendto fd5a:b03d:7f78:0:efd:4aca:49a9:e0ff%wpan0, port: 44861 length = 2 20190528 113028.722 DISCONNECT ===> Client2  E0 00

Error: BrokerRecvTask can't receive a packet from the broker errno=0 Client2

20190528 113038.750 CONNECT <--- Client2  0D 04 04 01 00 0A 43 6C 69 65 6E 74 32

20190528 113038.833 CONNECT ===> Client2  10 13 00 04 4D 51 54 54 04 02 00 0A 00 07 43 6C 69 65 6E 74 32

20190528 113039.225 CONNACK <=== Client2  20 02 00 00

20190528 113039.225 CONNACK ---> Client2  03 05 00 unicast sendto fd5a:b03d:7f78:0:efd:4aca:49a9:e0ff%wpan0, port: 38693 length = 3

20190528 113039.274 PUBLISH 0003 <--- Client2  91 0C 21 00 01 00 03 7B 22 4D 61 63 68 69 6E 65 22 3A 7B 22 49 64 22 3A 22 43 6C 69 65 6E 74 32 22 2C 22 54 65 6D 70 65 72 61 74 75 72 65 22 3A 35 32 2E 30 37 2C 22 50 72 65 73 73 75 72 65 22 3A 30 7D 2C 22 41 6D 62 69 65 6E 74 22 3A 7B 22 54 65 6D 70 65 72 61 74 75 72 65 22 3A 30 2C 22 48 75 6D 69 64 69 74 79 22 3A 30 7D 2C 22 54 69 6D 65 43 72 65 61 74 65 64 22 3A 22 32 30 31 39 2D 30 31 2D 30 31 54 30 30 3A 30 31 3A 31 39 22 7D

20190528 113039.274 PUBACK 0003 ---> Client2  07 0D 00 01 00 03 02 unicast sendto fd5a:b03d:7f78:0:efd:4aca:49a9:e0ff%wpan0, port: 38693 length = 7 20190528 113039.298 DISCONNECT <--- Client2  02 18

20190528 113039.298 DISCONNECT ---> Client2  02 18 unicast sendto fd5a:b03d:7f78:0:efd:4aca:49a9:e0ff%wpan0, port: 38693 length = 2 20190528 113039.299 DISCONNECT ===> Client2  E0 00

Error: BrokerRecvTask can't receive a packet from the broker errno=0 Client2 `

jelalanne commented 5 years ago

Sorry for text quality

ty4tw commented 5 years ago

Hi,

Why broker returns DISCONNECT?

Specification 3.1.1 defines DISCONNECT as follows: 3.14 DISCONNECT – Disconnect notification The DISCONNECT Packet is the final Control Packet sent from the Client to the Server. It indicates that 1 the Client is disconnecting cleanly.

The GW cannot recieve the out of sequence DISCONNECT message.

So, nothing wrong about the GW.

jelalanne commented 5 years ago

Do you have any clue about how to avoid this step?

ty4tw commented 5 years ago

which broker you are using?

jelalanne commented 5 years ago

Mosquitto TLS v1.2

ty4tw commented 5 years ago

This GW doesn't support MQTT V.5 yet. Could you use the V3.1.1 broker?

jelalanne commented 5 years ago

Ok i'll downgrade it and update you afterward

jelalanne commented 5 years ago

I just saw that we are using v3.1 (using command mosquitto -V)

ty4tw commented 5 years ago

Hi,

Could you try to use iot.eclipse.org broker ?

Set line17-18 in gateway.conf as follows and rerun.

BrokerName=iot.eclipse.org
BrokerPortNo=1883

If the same error occurs, it's better to ask the mosquitto project.

jelalanne commented 5 years ago

Hi, It works perfectly with the default broker, but not with mosquitto.

Thanks for your help I will try to see with them.

jelalanne commented 5 years ago

Hi @ty4tw , I'm coming back to you. It seems that the Disconnect ACK is sent to the client before being sent to the Broker (I don't know why, but it does send it to the Broker), so when the program tries to send the disconnect ack to the broker, the response is not received because the client does not exist anymore, so it gives me an error with code 0. Do you have any idea on how to repare that? Thanks a lot for your time

ty4tw commented 5 years ago

Hi, DISCONNECT ACK is not defined by MQTT specification 3.1.1.

jelalanne commented 5 years ago

I don't know why it's happening on both online broker and local one. Only local broker reports an error. I can't find any answer on mosquitto forums.

capture_client_unstable_10may capture_raspi_exec_gw_mqtt-sn_amqp

jelalanne commented 5 years ago

I'm using NJH library binaries for the clients' side, may this be linked? (https://github.com/njh/mqtt-sn-tools)

rwe1980 commented 5 years ago

Same issue here. I used docker to test different version of mosquitto. The gateway does not work with all version after 1.4.12. (AggregatingGateway=YES)

ty4tw commented 5 years ago

PUBLISH message you sent is invalid. MsgId od QoS0 should be 0, not 00 02. Gateway of latest develop branch rejects such wrong PUBLISH message.