Skip to main content



      Home
Home » Eclipse Projects » Paho » MQTT Client connect fails(MQTT client fails to connect - returns -1 RC value)
MQTT Client connect fails [message #1779589] Tue, 09 January 2018 21:35 Go to next message
Eclipse UserFriend
Hi

I am very new to MQTT, and I am trying to use the MQTT libraries as provided by the
Paho-MQTT -C-windows 1.2.0 release

I am using an MS Visual Studio 2015 software to create the solution and i have provided all the necessary includes and linker files.

The MS project builds and when I attempt to run it, the program fails.

the following are my set up

#define ADDRESS "tcp://m2m.eclipse.org:1883 "
#define CLIENTID "ExampleClientPub"
#define TOPIC "MQTT test"
#define PAYLOAD "Hello World!"
#define QOS 1
#define TIMEOUT 10000L

Stepping through the code, the project always fails at rc = -1

if ((rc = MQTTClient_connect(client, &conn_opts)) != MQTTCLIENT_SUCCESS)
{
printf("Failed to connect, return code %d\n", rc);
exit(-1);
}

What am I doing wrong? are the ADDRESS and CLIENTID values wrong?

Thank you in advance

Liwaa
Re: MQTT Client connect fails [message #1780169 is a reply to message #1779589] Thu, 18 January 2018 05:26 Go to previous messageGo to next message
Eclipse UserFriend
You can get a trace by setting the environment variable MQTT_C_CLIENT_TRACE=ON which might provide more information.
Re: MQTT Client connect fails [message #1793724 is a reply to message #1780169] Tue, 14 August 2018 11:05 Go to previous messageGo to next message
Eclipse UserFriend
Hi,
I am also getting same error but i am using eclipse paho c client on linux.
Please find attached trace.
Help me to solve this issue.
I am suing version 1.2

Regards,
Dhananjay Patil

  • Attachment: trace.txt
    (Size: 230.03KB, Downloaded 312 times)

[Updated on: Tue, 14 August 2018 11:10] by Moderator

Re: MQTT Client connect fails [message #1795295 is a reply to message #1793724] Thu, 20 September 2018 00:46 Go to previous messageGo to next message
Eclipse UserFriend
That trace shows no CONNACK response from the server to the connection request, and then a socket error on the connection. I would check the MQTT server for any errors, and the networking to see if there is any problem there. You could run a local MQTT server like Mosquitto to check that the application is working correctly.
Re: MQTT Client connect fails [message #1828942 is a reply to message #1793724] Mon, 22 June 2020 13:53 Go to previous message
Eclipse UserFriend
please show me your code
Previous Topic:MQTT C++ Embedded for Linux - Subscribe Messages Not Showing Up until Unsubscribe
Next Topic:Paho-MQTT is not able to connect more than 339 connections
Goto Forum:
  


Current Time: Thu Jun 19 23:25:36 EDT 2025

Powered by FUDForum. Page generated in 0.04144 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top