Jump to content


Error using MQTT


  • Please log in to reply
3 replies to this topic

#1 pramod2181



  • Members
  • Pip
  • 9 posts

Posted 06 January 2015 - 01:55 PM


I'm trying to send a certain data to the carriots using the MQTT code given in the MQTT documentation, but while doing so I'm getting the following error:


[Errno 10061] No connection could be made because the target machine actively refused it


Please, help me in resolving it.

I'm also copying the code that i have used.

Here, I replaced YOUR_APIKEY with the apikey of my account and the ID_DEVELOPER_DEVICE with the device ID to which I want to send data to.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Client paho-mqtt CarriotsMqttServer
# main.py
import paho.mqtt.publish as publish
from json import dumps
from ssl import PROTOCOL_TLSv1

class CarriotsMqttClient():
    host = 'mqtt.carriots.com'
    port = '1883'
    auth = {}
    topic = '%s/streams'
    tls = None

    def __init__(self, auth, tls=None):
        self.auth = auth
        self.topic = '%s/streams' % auth['username']
        if tls:
            self.tls = tls
            self.port = '8883'

    def publish(self, msg):
            publish.single(topic=self.topic, payload=msg, hostname=self.host, auth=self.auth, tls=self.tls, port=self.port)
        except Exception, ex:
            print ex

if __name__ == '__main__':
    auth = {'username': 'YOUR_APIKEY, 'password': ''}
    #tls_dict = {'ca_certs': 'ca_certs.crt', 'tls_version': PROTOCOL_TLSv1}  # ssl version
    msg_dict = {'protocol': 'v2', 'device': 'ID_DEVELOPER_DEVICE', 'at': 'now', 'data': {'temp': 21, 'hum':58}}
    client_mqtt = CarriotsMqttClient(auth=auth)                     # non ssl version
    #client_mqtt = CarriotsMqttClient(auth=auth, tls=tls_dict)      # ssl version


#2 jpastor


    Development leader

  • Administrators
  • 178 posts

Posted 07 January 2015 - 08:52 AM

Hello pramod2181


I'm testing your code and am getting the data without problems. I only added a single quotation mark in the "ApiKey" field.


Attached File  mqtt.jpg   59.5K   24 downloads


Hope it helps!


#3 pramod2181



  • Members
  • Pip
  • 9 posts

Posted 07 January 2015 - 11:57 AM

Hi jpastor,

I guess I got the above error due to the proxy settings of my organization. Please guide me on including the proxy settings in the above code. I also searched in the MQTT documentation, but unable to find it anywhere.


Looking forward for your prompt reply. 

#4 jpastor


    Development leader

  • Administrators
  • 178 posts

Posted 09 January 2015 - 08:12 AM

Hello pramod2181

Sometimes Carriots bans some IP addresses due to suspicious activity.

In order to verify that the IP address of your organization is not one of them. Could you send an email to support@carriots.com with the public IP address of your organization?


Best Regards

Also tagged with one or more of these keywords: MQTT

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users