eclipse-paho / paho.mqtt.golang

Other
2.77k stars 534 forks source link

Need to get explicit ACK events #660

Closed levb closed 11 months ago

levb commented 11 months ago

I am using this client for testing and benchmarking MQTT 3.1.1. broker functionality, and would like to be able to measure times to receive the various ack packets - CONNACK, SUBACK, PUBACK/REC/COMP. It appears that token.Wait() does not always accomplish what I need.

Specifically:

I may be missing something in the documentation, if so please point me to the right place, or a code/test sample that does it?

MattBrittan commented 11 months ago

I'm sorry but your requirements are very specific and really outside of the scope of this client. As such I'd suggest that you clone this (or the v5 client) and use that as a base to write your own benchmarking tool.

For CONNECT, what is the difference in getting the OnConnectHandler called vs. t := client.Connect; t.Wait()?

In terms of timing not a lot (the token will be closed a bit later than OnConnectHandler is called). These two things have differing purposes (OnConnectHandler will be called if/when the client reconnects as well as for the initial connection).

For QOS2 PUBLISH: is it possible to get the 3 distinct timestamps for PUBREC received, PUBREL sent, and PUBCOMP received? And what exactly will token.Wait() wait for?

The token will be complete when the transaction completes (for a QOS2 publish that means PUBCOMP is received)..

For QOS2 SUBSCRIBE: same, can I get the timing of the 3 packets involved PUBLISH received, PUBREC sent, PUBREL received?

No; that's really outside of the scope of this client.

Confirm that token.Wait() on Subscribe fires on SUBACK

Correct.

Sorry - for this kind of thing you are going to need to look at the libraries code (the v5 client is probably easier to follow) and make your own modifications (it's unlikely these would be accepted as a PR because they would add complexity but be of use to very few users).

levb commented 11 months ago

Thanks for the prompt explanation, @MattBrittan!