Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscription call back not found when packet length is more than 127 #185

Closed
cbitter78 opened this issue Nov 4, 2020 · 2 comments
Closed

Comments

@cbitter78
Copy link

Overview

If you send data that results in a packet that exceeds 127 bytes then the packets are read but it does not find the subscription because it shows the len of the subscription as 0 If I send 127 bytes it works, 128 and up does not.

The data that was sent to my feed is (I only sent the data once)

{"name": "vend", "id": "JThpGd", "slot": 2, "args": ["Charles", "Ballast Point             "]}   

The feed name is 32 bytes cbitter78/feeds/iot-beer-command

DEBUG OUTPUT

21:15:24.249 -> Read data:		0 [0x30], 
21:15:24.249 -> Packet Type:		0 [0x30], 
21:15:24.249 -> Read data:		  [0x80], 
21:15:24.249 -> Read data:		  [0x01], 
21:15:24.249 -> Packet Length:	128
21:15:24.249 -> Read data:		  [0x00],   [0x20], c [0x63], b [0x62], i [0x69], t [0x74], t [0x74], e [0x65], 
21:15:24.249 -> 	r [0x72], 7 [0x37], 8 [0x38], / [0x2F], f [0x66], e [0x65], e [0x65], d [0x64], 
21:15:24.249 -> 	s [0x73], / [0x2F], i [0x69], o [0x6F], t [0x74], - [0x2D], b [0x62], e [0x65], 
21:15:24.249 -> 	e [0x65], r [0x72], - [0x2D], c [0x63], o [0x6F], m [0x6D], m [0x6D], a [0x61], 
21:15:24.249 -> 	n [0x6E], d [0x64], { [0x7B], " [0x22], n [0x6E], a [0x61], m [0x6D], e [0x65], 
21:15:24.249 -> 	" [0x22], : [0x3A],   [0x20], " [0x22], v [0x76], e [0x65], n [0x6E], d [0x64], 
21:15:24.249 -> 	" [0x22], , [0x2C],   [0x20], " [0x22], i [0x69], d [0x64], " [0x22], : [0x3A], 
21:15:24.249 -> 	  [0x20], " [0x22], J [0x4A], T [0x54], h [0x68], p [0x70], G [0x47], d [0x64], 
21:15:24.249 -> 	" [0x22], , [0x2C],   [0x20], " [0x22], s [0x73], l [0x6C], o [0x6F], t [0x74], 
21:15:24.249 -> 	" [0x22], : [0x3A],   [0x20], 2 [0x32], , [0x2C],   [0x20], " [0x22], a [0x61], 
21:15:24.249 -> 	r [0x72], g [0x67], s [0x73], " [0x22], : [0x3A],   [0x20], [ [0x5B], " [0x22], 
21:15:24.249 -> 	C [0x43], h [0x68], a [0x61], r [0x72], l [0x6C], e [0x65], s [0x73], " [0x22], 
21:15:24.285 -> 	, [0x2C],   [0x20], " [0x22], B [0x42], a [0x61], l [0x6C], l [0x6C], a [0x61], 
21:15:24.285 -> 	s [0x73], t [0x74],   [0x20], P [0x50], o [0x6F], i [0x69], n [0x6E], t [0x74], 
21:15:24.285 -> 	  [0x20],   [0x20],   [0x20],   [0x20],   [0x20],   [0x20],   [0x20],   [0x20], 
21:15:24.285 -> 	  [0x20],   [0x20],   [0x20],   [0x20],   [0x20], " [0x22], ] [0x5D], } [0x7D], 
21:15:24.285 -> 	
21:15:24.285 -> Packet len: 131
21:15:24.285 -> 	0 [0x30],   [0x80],   [0x01],   [0x00],   [0x20], c [0x63], b [0x62], i [0x69], 
21:15:24.285 -> 	t [0x74], t [0x74], e [0x65], r [0x72], 7 [0x37], 8 [0x38], / [0x2F], f [0x66], 
21:15:24.285 -> 	e [0x65], e [0x65], d [0x64], s [0x73], / [0x2F], i [0x69], o [0x6F], t [0x74], 
21:15:24.285 -> 	- [0x2D], b [0x62], e [0x65], e [0x65], r [0x72], - [0x2D], c [0x63], o [0x6F], 
21:15:24.285 -> 	m [0x6D], m [0x6D], a [0x61], n [0x6E], d [0x64], { [0x7B], " [0x22], n [0x6E], 
21:15:24.285 -> 	a [0x61], m [0x6D], e [0x65], " [0x22], : [0x3A],   [0x20], " [0x22], v [0x76], 
21:15:24.285 -> 	e [0x65], n [0x6E], d [0x64], " [0x22], , [0x2C],   [0x20], " [0x22], i [0x69], 
21:15:24.285 -> 	d [0x64], " [0x22], : [0x3A],   [0x20], " [0x22], J [0x4A], T [0x54], h [0x68], 
21:15:24.285 -> 	p [0x70], G [0x47], d [0x64], " [0x22], , [0x2C],   [0x20], " [0x22], s [0x73], 
21:15:24.285 -> 	l [0x6C], o [0x6F], t [0x74], " [0x22], : [0x3A],   [0x20], 2 [0x32], , [0x2C], 
21:15:24.285 -> 	  [0x20], " [0x22], a [0x61], r [0x72], g [0x67], s [0x73], " [0x22], : [0x3A], 
21:15:24.285 -> 	  [0x20], [ [0x5B], " [0x22], C [0x43], h [0x68], a [0x61], r [0x72], l [0x6C], 
21:15:24.285 -> 	e [0x65], s [0x73], " [0x22], , [0x2C],   [0x20], " [0x22], B [0x42], a [0x61], 
21:15:24.285 -> 	l [0x6C], l [0x6C], a [0x61], s [0x73], t [0x74],   [0x20], P [0x50], o [0x6F], 
21:15:24.285 -> 	i [0x69], n [0x6E], t [0x74],   [0x20],   [0x20],   [0x20],   [0x20],   [0x20], 
21:15:24.285 -> 	  [0x20],   [0x20],   [0x20],   [0x20],   [0x20],   [0x20],   [0x20],   [0x20], 
21:15:24.285 -> 	" [0x22], ] [0x5D], } [0x7D], 
21:15:24.285 -> Looking for subscription len 0

From my novice reading of the code the debug message Looking for subscription len shows it thinks the subscription name has zero length.

I tried setting

SUBSCRIPTIONDATALEN: 250
MAXBUFFERSIZE: 250

This had no effect. I still could only send 93 bytes.

Reproduce

Subscribe to a feed and read it using readSubscription method. See this example then post enough bytes to the subscribed feed to exceed 127 bytes (this includes the feed name)

You will need to set MQTT_DEBUG

Info

  • Board: Adafruit Feather M0
  • Arduino IDE version: 1.8.13
@maseth
Copy link

maseth commented Nov 15, 2020

I am also struggling with this bug.
I dug a little inside this code and found that the problem is in topic length decoding.
Look into Adafruit_MQTT.cpp line 494 there is a hardcoded reading 4-th byte to get topic length
topiclen = buffer[3];
in case of packet length grater than 127 topic length becomes 5-th byte.

@xdylanm
Copy link

xdylanm commented May 14, 2021

this should be resolved with PR #193

@brentru brentru closed this as completed May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants