Mqtt payload broken?

When i set a received payload to a variable in mqtt blocks, and try to do something with it,
it gives me this error

"Expecting a (thing), but getting an undefined"

Can you post a script that isn't working for you please

Well this has happened every time ive used mqtt in the last month but ok

This is from one project


and this is from the project its communicating with

which ones giving the error?

And you are sure it's not your code?
The error you explained didn't include "inside a custom block:" which (assuming you copied the error exactly) means you have an error in your code.

image

can you send both projects so i can have a look please

click the flag in both, in the first one, enter this in the prompt: broker:emqx.examplesite.io

in the second one, in the editor, wait until (no) doesnt equal 0. then run the split (no) by [letter]

You can dump the variable content with
Examplesite script pic (1)

Response is not a plain text but Object (Uint8Array). You can try
Examplesite script pic

"Join" tries to create something readable from anything.
Or maybe Jens expanded the "join" to work with the binary data :smile:

The reason is simple:according to my experiements,you can only use empty slots to get stuff from response

I wonder if you come up with something a bit simpler that gives an error that you think is due to a problem with the MQTT library - your 1st script is too complicated for me to follow :slight_smile:

The second one is not really valid.
The idea behind the subscribe is that you call it once and then use the on each message callback to action any incoming messages. You don't put the block itself into an infinite loop

I know whats happening, I experienced it yesterday when building an mqtt program. Using ring variables for the response gives an object for some reason.

@mr_owlssssnap2 use this block to change the response to text:

Snappit Hosting script pic

Can you post a simple example of the issue?

Notice I'm using the request ring variable.

Publish something to the topic, and look at what the sprite says.

Thank you - I finally understand :slight_smile:

I would say that is a bug and will have to look into a bit further

(We changed the way the payload is returned by default but since it looks like text - it never occurred to me that Snap! might not think it's text :slight_smile:

The workaround for the moment is to just stick a true into the options and the payload will be returned in the same manner as it was prior to V8.1

untitled script pic (72)

Paging @xavierpi - we might need to tweak something :slight_smile:

I think I've fixed it - just going to make sure Xavier is happy with it before making a PR to Jens

@mr_owlssssnap2
The block is now fixed in latest dev version - thanks for the report :slight_smile:

Thanks to @joecooldoo for explaining it to me :slight_smile:

thanks

@here thanks for all the answers!

I thought this was a feature!