alihanyalcin / mqtt-wrapper

mqtt-wrapper provides easy-to-use MQTTv3 and MQTTv5 client
MIT License
14 stars 0 forks source link

Mqtt5 Requests Response Topic #11

Open sabsantina opened 3 years ago

sabsantina commented 3 years ago

Would it be possible to allow someone to pass the response topic for this function

// Request sends a message to broker and waits for the response.
func (m *mqttv5) Request(topic string, payload interface{}, timeout time.Duration, h handler)

At the moment, the current format where the response topic is hardcoded does not allow for what I need. Thank you

alihanyalcin commented 3 years ago

Hi @sabsantina, I've added RequestWith method for mqttv5 client. Is it cover your need?

https://github.com/alihanyalcin/mqtt-wrapper/blob/master/mqttv5.go#L92

sabsantina commented 3 years ago

@alihanyalcin, I've tried to use the RequestWith method as it currently is coded and it should cover my needs however I'm always getting a timeout error. At the moment, I am trying to write some tests with gomega/ginkgo to test the payload of specific response topics. I've tried different ways of attempting this but from what I can see the handler is never reached and it just times out.

alihanyalcin commented 3 years ago

I have tried request-response with timeout but I did not get any timeout. Which mqtt broker did you use to test it?

sabsantina commented 3 years ago

The broker uses paho and is installed in a docker image. It requires SSL certificates to be accessed.