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

mqtt 5.0 Request Response using emqtt library. How set Properties? #195

Closed
cocoaway opened this issue Apr 16, 2023 · 6 comments
Closed

mqtt 5.0 Request Response using emqtt library. How set Properties? #195

cocoaway opened this issue Apr 16, 2023 · 6 comments

Comments

@cocoaway
Copy link

No description provided.

@cocoaway
Copy link
Author

Hello,
I'm trying to make a request/response publish but is not clear how set Response topic and Correlation data in
:emqtt.publish(Client, Topic, Properties, Payload, PubOpts)

Can you provide how set Properties ?

Thx.

Luca

@cocoaway cocoaway changed the title mqtt 5.0 Request Response using emit library. mqtt 5.0 Request Response using emqtt library. How set Properties? Apr 16, 2023
@emiltin
Copy link

emiltin commented Sep 19, 2023

Did you find an answer to this? I'm also wondering how to set the response topic.

@qzhuyan
Copy link
Contributor

qzhuyan commented Sep 19, 2023

just set in Properties map, take a look in emqtt_props.erl.

@emiltin
Copy link

emiltin commented Sep 19, 2023

Thank you. Right, I can set 'Response-Topic' to a string, and I now see this logged when I publish:

[debug] [clientid: "emqtt-ab49cf24b912acf684db", msg: ~c"SEND_Data", packet: {:mqtt_packet, {:mqtt_packet_header, 3, false, 1, false}, {:mqtt_packet_publish, "command/tlc_582a/plan", 14, %{"Response-Topic": "response/tlc_582a"}}, "7"}, socket: #Port<0.30>]

But when another client receives this I don't see any properties:

%{
  client_pid: #PID<0.189.0>,
  dup: false,
  packet_id: 1,
  payload: "7",
  properties: %{},
  qos: 1,
  retain: false,
  topic: "command/tlc_582a/plan",
  via: #Port<0.12>
}

Shouldn't I see the Response-Topic as a property when I receive the message? Or is there another way to get it?

Note: I'm using Elixir.

@thalesmg
Copy link
Contributor

Did you connect using MQTT protocol version 5?

{:ok, c} = :emqtt.start_link(proto_ver: :v5, ...)

@emiltin
Copy link

emiltin commented Sep 19, 2023

Great tip! I thought I did, but realized I only did so in one of the clients, not the other. Now it works 👍

@qzhuyan qzhuyan closed this as completed Sep 21, 2023
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