0

QOS 1 not responding
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

QOS 1 not responding

by baxtertidwell on Thu Dec 26, 2019 5:03 pm

Feather M4 Express with AirLift co-processor. Using adafruit_minimqtt.

Raspberry Pi Zero W with mosquitto as broker. Command line:

Code: Select all | TOGGLE FULL SIZE
mosquitto_sub -h localhost -t "baxtertidwell/feeds/photocell" -q 1 -v -d
Notice qos set to 1.

On the M4 client, this line works, and packets are received and displayed on the Pi:

Code: Select all | TOGGLE FULL SIZE
print(' Sending photocell value:', '{:4}'.format(photocell_val), '...', end='')
mqtt_client.publish(photocell_feed, photocell_val, qos=0)
But changing qos=1, mosquitto recieves and tries to ack, but M4 either doesn't get it or doesn't respond.

Here's the M4 client:

Code: Select all | TOGGLE FULL SIZE
Sending photocell value:  680 ...Published to baxtertidwell/feeds/photocell with PID 2
Sending photocell value:  608 ...Published to baxtertidwell/feeds/photocell with PID 3
And the debug info on the Pi/mosquitto:

Code: Select all | TOGGLE FULL SIZE
Client mosqsub|847-raspi-stair sending CONNECT
Client mosqsub|847-raspi-stair received CONNACK (0)
Client mosqsub|847-raspi-stair sending SUBSCRIBE (Mid: 1, Topic: baxtertidwell/feeds/photocell, QoS: 1)
Client mosqsub|847-raspi-stair received SUBACK
Subscribed (mid: 1): 1
Client mosqsub|847-raspi-stair received PUBLISH (d0, q1, r0, m1, 'baxtertidwell/feeds/photocell', ... (3 bytes))
Client mosqsub|847-raspi-stair sending PUBACK (Mid: 1)
baxtertidwell/feeds/photocell 680
Client mosqsub|847-raspi-stair sending PINGREQ
Client mosqsub|847-raspi-stair received PINGRESP
Client mosqsub|847-raspi-stair sending PINGREQ
Client mosqsub|847-raspi-stair received PINGRESP
Client mosqsub|847-raspi-stair sending PINGREQ
Client mosqsub|847-raspi-stair received PINGRESP
Client mosqsub|847-raspi-stair sending PINGREQ
Etc...

It's like the M4 receives the ack, because it sends another packet (reading 608), but then everything just stops.

It seems like it should work magically by changing the qos on the publish line, but I can't find any documentation that addresses my freezing situation. Do I need to have a subscription on the M4 client side to receive the ack?

baxtertidwell
 
Posts: 39
Joined: Mon Jan 07, 2013 6:16 pm

Re: QOS 1 not responding

by brubell on Fri Dec 27, 2019 10:10 am

It seems like the client is receiving a PUBACK, does the sent value of 680 appear in your broker's logs?

brubell
 
Posts: 696
Joined: Fri Jul 17, 2015 10:33 pm

Re: QOS 1 not responding

by baxtertidwell on Fri Dec 27, 2019 11:56 am

Yes, 680 is received and a database logger inserts it into the database. I agree that the client is receiving the PUBACK, because it sends another value. that value, 608, is not inserted into the database.

A new thing today, and I don't know why. Now the client is throwing an exception. Yesterday, it just waited forever. Now it's timing out.

Code: Select all | TOGGLE FULL SIZE
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Connecting to raspi-stairs
Connected to MQTT Broker!
Flags: 0
 RC: 0
Subscribed to baxtertidwell/feeds/onoff with QOS level 1
. Sending photocell value:  834 ...Sent!
. Sending photocell value:  742 ...Traceback (most recent call last):
  File "code.py", line 164, in <module>
  File "adafruit_minimqtt.py", line 395, in publish
  File "adafruit_minimqtt.py", line 643, in _wait_for_msg
  File "adafruit_esp32spi/adafruit_esp32spi_socket.py", line 137, in recv
  File "adafruit_esp32spi/adafruit_esp32spi_socket.py", line 173, in available
  File "adafruit_esp32spi/adafruit_esp32spi.py", line 676, in socket_available
  File "adafruit_esp32spi/adafruit_esp32spi.py", line 326, in _send_command_get_response
  File "adafruit_esp32spi/adafruit_esp32spi.py", line 315, in _wait_response_cmd
  File "adafruit_esp32spi/adafruit_esp32spi.py", line 299, in _wait_response_cmd
  File "adafruit_esp32spi/adafruit_esp32spi.py", line 278, in _wait_spi_char
RuntimeError: Timed out waiting for SPI char
Line 164 is the publish call. This is still happening on the second call. It looks as though the first call was ACK'd just fine.

Does this give us any more insight?

baxtertidwell
 
Posts: 39
Joined: Mon Jan 07, 2013 6:16 pm

Re: QOS 1 not responding

by brubell on Thu Jan 02, 2020 3:52 pm

Ok - I have a concrete answer for you. Adafruit IO's MQTT Broker does not support QoS 1 for publishing data. We do support a QoS of 1 for subscribing to Feeds.

brubell
 
Posts: 696
Joined: Fri Jul 17, 2015 10:33 pm

Re: QOS 1 not responding

by baxtertidwell on Thu Jan 02, 2020 5:00 pm

Well, that would explain things. Lady Ada has a video where she mentions that most people use QOS 1. She doesn't mention that that's only for subscribing. Any thoughts of supporting QOS 1 or 2 for publishing in the future?

baxtertidwell
 
Posts: 39
Joined: Mon Jan 07, 2013 6:16 pm

Re: QOS 1 not responding

by brubell on Thu Jan 02, 2020 5:23 pm

baxtertidwell wrote:Well, that would explain things. Lady Ada has a video where she mentions that most people use QOS 1. She doesn't mention that that's only for subscribing. Any thoughts of supporting QOS 1 or 2 for publishing in the future?


No current plans since QoS is difficult to support at scale for publishing since it occurs more often in code than subscribing.

brubell
 
Posts: 696
Joined: Fri Jul 17, 2015 10:33 pm

Please be positive and constructive with your questions and comments.