dotnet / MQTTnet

MQTTnet is a high performance .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker). The implementation is based on the documentation from http://mqtt.org/.
MIT License
4.51k stars 1.07k forks source link

Can i connect One ManagedClient to multiple brokers. #900

Closed ameeena closed 4 years ago

ameeena commented 4 years ago

I have an MQTT client, and i have 2 brokers. One is a mosquitto broker and another one is MQTT net broker. I want to connect my client to both the brokers. Is it possible to achieve this? I'm getting an exception thrown when i do that : MQTTnet.Exceptions.MqttProtocolViolationException: 'It is not allowed to connect with a server after the connection is established.'

Thanks

Which project is your question related to?

SeppPenner commented 4 years ago

I don't think that this is possible. You have 2 different options according to my understanding:

  1. Use two clients (One connecting to mosquitto, the other connecting to MQTTnet).
  2. Build some kind of "Proxy broker" that gets requests from MQTTnet and mosquitto and figures as a kind of MQTT proxy for your client.
chkr1011 commented 4 years ago

Sorry but this is not possible. Why do you want to do such things?

ameeena commented 4 years ago

Oh thank you for the replies :) I actually wanted to publish to the brokers because there are different clients listening on different brokers and i wanted to connect to those brokers. But ya like SeppPenner replied i will try the proxy broker option. Thanks again :)