Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » MQTT Client connect fails(MQTT client fails to connect - returns -1 RC value)
MQTT Client connect fails [message #1779589] Wed, 10 January 2018 02:35 Go to next message
Liwaa Alnashi is currently offline Liwaa AlnashiFriend
Messages: 1
Registered: January 2018
Junior Member
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 10:26 Go to previous messageGo to next message
Ian Craggs is currently offline Ian CraggsFriend
Messages: 83
Registered: March 2013
Member
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 15:05 Go to previous messageGo to next message
Dhananjay  Patil is currently offline Dhananjay PatilFriend
Messages: 2
Registered: August 2018
Junior Member
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 251 times)

[Updated on: Tue, 14 August 2018 15:10]

Report message to a moderator

Re: MQTT Client connect fails [message #1795295 is a reply to message #1793724] Thu, 20 September 2018 04:46 Go to previous messageGo to next message
Ian Craggs is currently offline Ian CraggsFriend
Messages: 83
Registered: March 2013
Member
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 17:53 Go to previous message
youssef touati is currently offline youssef touatiFriend
Messages: 1
Registered: June 2020
Junior Member
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: Sat Apr 27 00:50:05 GMT 2024

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

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

Back to the top