Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] C++ client crash during connect

Hi Ian,

Thank you for the reply.

The variable http_proxy is not setted in my enviroment variables

Il 09/08/2020 11:52, Ian Craggs ha scritto:

Hi Fausto,

Some thoughts.

1) Do you have an empty http_proxy environment variable? Currently the C client has faulty HTTP proxy code for websockets (which I will fix).

2) If it isn't 1) Try taking a C client trace (see the README for instructions on setting the environment variables) to see what errors there might be.

Ian

On 07/08/2020 17:24, Fausto Papandrea wrote:

Hi, I have downloaded the paho-mqtt-c and paho-mqtt-cpp sources from github and I have compiled them.

This is my test code (I got it from the eclipse page):

#include "mqtt/client.h"

int main(int argc, char *argv[])

{
  const std::string TOPIC { "hello" };
  const std::string PAYLOAD1 { "Hello World!" };
  const char* PAYLOAD2 = "Hi there!";
  mqtt::client client("tcp://localhost:1883", "TestClient");
  mqtt::connect_options connectOptions;
  connectOptions.set_keep_alive_interval(20);
  connectOptions.set_clean_session(true);
  try
  {
    client.connect(connectOptions);
    const mqtt::message_ptr& message = mqtt::make_message(TOPIC, PAYLOAD1);
//    message->set_qos(3);
    client.publish(message);
    client.publish(TOPIC, PAYLOAD2, strlen(PAYLOAD2), 0, false);
    client.disconnect();
  }
  catch (const mqtt::exception& e)
  {
    qDebug() << "Error: " << e.what() << " [" << e.get_reason_code() << "]";
    return 1;
  }
  return 0;
}

It crashes inside the client.connect(), in particular in file MQTTAsync.c(line 1815) in function MQTTAsync_processCommand() here:

if (command->client->c->connect_state == NOT_IN_PROGRESS)
	rc = SOCKET_ERROR;

because command->client->c is null.

Any suggestions? Thank you

_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/paho-dev

_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/paho-dev

Back to the top