1

I just try to connect to my Bluemix IOT Foundation instance with a mosquitto mqtt client. I configured everything as described in https://docs.internetofthings.ibmcloud.com/messaging/devices.html. My python client connects but disconnect after a second.

import paho.mqtt.client as mqtt

def on_connect(client, userdata, flags, rc):
    print("Connected with result code "+str(rc))
    client.subscribe("$SYS/#")

def on_disconnect(client, userdata, rc):
print("Disconnect with result code "+str(rc))

def on_message(client, userdata, msg):
    print(msg.topic+" "+str(msg.payload))

client = mqtt.Client(client_id="d:gixu3a:RaspberryPi:abcdefgh")

client.on_connect    = on_connect
client.on_message    = on_message
client.on_disconnect = on_disconnect

client.username_pw_set("use-token-auth", password="XXXXXXX")

client.connect("gixu3a.messaging.internetofthings.ibmcloud.com", 1883, 60)

client.loop_forever()

Return code when I get disconnected is 1 and I can also see the connection inside the IOT Foundation dashboard:

Connection State
Disconnected on Saturday, October 10, 2015 at 9:10:22 PM from 89.140.177.130 
with an insecure connection Refresh

Can I get any logfile from the Bluemix side?

  • Are you still experiencing the same error today? There was some restructuring of DNS records that possibly affected your connection, but if that was the cause you should be back to working normally now. – ValerieLampkin Oct 12 '15 at 16:27

1 Answers1

1

It is because it is not accepting the topic as valid - devices can only subscribe to commands - try subscribing to something like "iot-2/cmd/acommand/fmt/json"

David Glance
  • 619
  • 5
  • 8