-1

I've made a snippet to connect to a remote mqtt server that I do not administrate, I know the Java message is accepted but the python message isn't. Any idea? I'm not familiar with python byte stuff.

I do JSON > byte stuff

In Java I can send a message with payload in byte or bytearray enter image description here

But in Python, the message is received but the admin report broker error

`b'{\n  "subject": "subject1",\n  "date": "Wed, 17 Feb 2021 13:27:32 +0100"\n}'` to topic `testtopic/testchannel`

abc being my json.

>>> 'abc'.encode('utf-8') b'abc'

>>> bytearray('abc', 'utf-8') bytearray(b'abc')

400 Bad Request: [{"error":"BadRequest","description":"date has invalid format"}]

python3: bytes vs bytearray, and converting to and from strings

4
  • Please do NOT post images of text, they are really hard to read and impossible for people that need to use screen readers. Commented Apr 20, 2021 at 10:35
  • Also update the question to show the actual code as described here: stackoverflow.com/help/minimal-reproducible-example Commented Apr 20, 2021 at 10:38
  • For the code it's default python paho mqtt. I can't get access to the broker's code so there no reproducible example I'm afraid Commented Apr 20, 2021 at 11:15
  • No, you need to show us a LOT more of your code, in the context of how it's actually used. What you've supplied tells us nothing about how it's interacting with the Paho code. Commented Apr 20, 2021 at 12:00

1 Answer 1

0

Ok so obviously, the date error is actually a date type error

The type was enforced.

Conclusion all the payload format are working.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.