|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Can't connect to MQTT broker |
« View previous topic :: View next topic » |
Author |
Message
|
Olivier GRACIANNE |
Posted: Wed Jul 04, 2018 6:30 am Post subject: Can't connect to MQTT broker |
|
|
Newbie
Joined: 04 Jul 2018 Posts: 3
|
Hello,
I'm pretty new in everything about MQTT, and just had some days documenting myself.
Now I want to create an MQTT client using C# and the M2MQTT Library. So I tried the following :
Code: |
MqttClient client = new MqttClient(hostName);
|
to create my client. Then :
Code: |
client.MqttMsgPublishReceived = msgReceiveCallback(); |
to react to messages. Then, obviously :
Code: |
client.Connect(Guid.NewGuid().ToString()); |
which talks pretty good by itself. And eventually :
Code: |
client.Subscribe(topics, qosLevels); |
which is also pretty clear.
But when I use the web interface of the broker to send a message, the listenners I wrote doesn't trigger.
I think that my client isn't even connected. But though I've looked for a solution the past few days, I can't find out what is not working.
Any idea ? |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Jul 04, 2018 9:42 am Post subject: Re: Can't connect to MQTT broker |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Olivier GRACIANNE wrote: |
Hello,
I'm pretty new in everything about MQTT, and just had some days documenting myself.
Now I want to create an MQTT client using C# and the M2MQTT Library. So I tried the following :
Code: |
MqttClient client = new MqttClient(hostName);
|
to create my client. Then :
Code: |
client.MqttMsgPublishReceived = msgReceiveCallback(); |
to react to messages. Then, obviously :
Code: |
client.Connect(Guid.NewGuid().ToString()); |
which talks pretty good by itself. And eventually :
Code: |
client.Subscribe(topics, qosLevels); |
which is also pretty clear.
But when I use the web interface of the broker to send a message, the listenners I wrote doesn't trigger.
I think that my client isn't even connected. But though I've looked for a solution the past few days, I can't find out what is not working.
Any idea ? |
Have you tried running the sample from MQExplorer? Remember that by default your MQTT server is not running.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Olivier GRACIANNE |
Posted: Wed Jul 04, 2018 11:31 pm Post subject: |
|
|
Newbie
Joined: 04 Jul 2018 Posts: 3
|
Actually, "hostName" in
Code: |
new MqttClient(hostName) |
hides a real machine hostname, running an MQTT server I can publish and subscribe to through the web interface I mentionned.
Though, I didn't try to run this code in MQExplorer as I don't have one  |
|
Back to top |
|
 |
Olivier GRACIANNE |
Posted: Thu Jul 05, 2018 1:13 am Post subject: |
|
|
Newbie
Joined: 04 Jul 2018 Posts: 3
|
Fixed.
This was a stupid problem of habilitation. I didn't have access to the machine I was trying to talk to.
Sorry for asking help I was not needing. |
|
Back to top |
|
 |
hughson |
Posted: Thu Jul 05, 2018 1:21 pm Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
Olivier GRACIANNE wrote: |
Sorry for asking help I was not needing. |
Don't worry about that
Sometimes writing out your problem as a question to others helps in solving it. Amazing how many times that happens.
Cheers,
Morag _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|