Not able to connect to Broker

Hi,
I am using paho (using python library) as my Client and trying to connect to HiveMQ. I am not able to connect to Broker. I am not ending up with any error so I am not able to understand where I am wrong. Here is my sample code.

import paho.mqtt.client as paho
import json

mqttBroker = “mqtt.dev-dis-cooling.net
port = 8883
MQTT_KEEPALIVE_INTERVAL = 60
MQTT_TOPIC = “Test1”

def on_publish(client, userdata, mid):
print(“Message Published”)

To message

def on_message(client, userdata, msg):
print("Message received on topic " + msg.topic + " with QoS " + str(msg.qos) + " and payload " + msg.payload)

To connect and publish json data

def on_connect(client, userdata, flags, rc):
client.subscribe(MQTT_TOPIC)
client.publish(MQTT_TOPIC, data)

Initiate MQTT Client

client = paho.Client()
client.on_connect = on_connect
client.connect(mqttBroker, 8883)

Hello @mathureshruti ,

Thank you for your interest in HiveMQ and MQTT!

You indicated that your Python app cannot connect to the broker.

  1. Please check if the port 8883 is open in your system.
  2. Confirm that another MQTT Client can connect from your system to your broker. To test, use MQTT CLI command line tool: Home - MQTT CLI

If you have further questions please do not hesitate to ask,
Kind regards
Dasha from HiveMQ team

Hello,

I tried both ways still i have the same problem. I am still not able to connect to broker.

I am using Juypter environment to write the python code (paho) for client.

Hi @mathureshruti ,

In case if you cannot connect to the broker:8883 with any MQTT Client, there is a chance that the port 8883 in your OS or in your Jupiter environment is blocked for any communication.

For us to help you, you need to provide some additional information. Please copy here the mqtt cli command and parameters you use and the error output.

Thanks,
Kind regards,
Dasha from HiveMQ team