Git Product home page Git Product logo

Comments (7)

fpagliughi avatar fpagliughi commented on August 18, 2024

For the SSL example, we use the certificates from the Paho C library test cases. But the broker must also be configured to use those certificates. We assume mosquitto as the broker. The basic instructions are in a comment at the top of the ssl_publish.cpp source code. But now I realize that the starting directory for mosquitto is incorrect.

First make sure no other instance of mosquitto is running:

$ sudo service mosquitto stop

Download/clone the Paho C library, then enter the top-level directory for it and run mosquitto from there with the test configuration file:

$ cd paho.mqtt.c
$ mosquitto -c test/tls-testing/mosquitto.conf
1496692100: mosquitto version 1.4.11 (build date Mon, 20 Feb 2017 22:47:27 +0000) starting
1496692100: Config loaded from test/tls-testing/mosquitto.conf.
...

Go into the C++ samples directory, and copy the file "test-root-ca.crt" from the C test directory (paho.mqtt.c/test/tls-testing) for the trust store for this program. Then run the sample.

$ cd paho.mqtt.cpp/src/samples
$ cp ../../../paho.mqtt.c/test/tls-testing/test-root-ca.crt .
$ ./ssl_publish 
Initializing for server 'ssl://localhost:18885'...
  ...OK

Connecting...
Waiting for the connection...
  ...OK

Sending message...
	Delivery complete for token: 1
  ...OK

Sending next message...
	Delivery complete for token: 2
  ...OK

Disconnecting...
  ...OK

$

from paho.mqtt.cpp.

priema avatar priema commented on August 18, 2024

I did it exactly that way but im getting the error code -13:

[100%] Linking CXX executable ssl_publish
[100%] Built target ssl_publish
pi@raspberrypi:~/temp/paho.mqtt.cpp $ cd src/samples/
pi@raspberrypi:~/temp/paho.mqtt.cpp/src/samples $ ./ssl_publish
Initializing for server 'ssl://localhost:18885'...
  ...OK

Connecting...
MQTT error [-13]

from paho.mqtt.cpp.

woohyeok avatar woohyeok commented on August 18, 2024

-13 Error Code indicates that Your Library does not support SSL.
Replace it with an MQTT library that supports SSL.

from paho.mqtt.cpp.

fpagliughi avatar fpagliughi commented on August 18, 2024

Oh, wow, how did I miss that!?! I just added that error to the C library a few weeks ago.

Thanks.

Yes, -13 means that the app is being linked against a version of the Paho C library which was not compiled to support SSL. It appears that you're building with CMake? I will check that the build system is linking to the correct library. (I primarily test with GNU Make, so a few things may have slipped by in the CMake and Autotools builds).

from paho.mqtt.cpp.

priema avatar priema commented on August 18, 2024

yes I build it with CMake..
what can I do to build it correct?

from paho.mqtt.cpp.

zhaoboc avatar zhaoboc commented on August 18, 2024

it's possible that ssl_publish is linked to paho-mqtt3a, which is paho async library without ssl:

    set(PAHO_MQTT_C paho-mqtt3a)
    target_link_libraries(ssl_publish
        ${PAHO_MQTT_C}
        ${PAHO_MQTT_CPP})

however in Makefile ssl_publish is linked to paho-mqtt3as correctly:

ssl_publish: ssl_publish.cpp
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< $(LDLIBS_SSL)

from paho.mqtt.cpp.

fpagliughi avatar fpagliughi commented on August 18, 2024

It appears that this was already fixed in the develop branch a few weeks ago. Try to pull the latest code, checkout that branch, and try again. It should work.

from paho.mqtt.cpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.