romuloceccon / lightmqtt

MQTT 3.1.1 client library written in pure C, fully asynchronous, supporting QoS 0, 1 and 2 messages and large payloads
MIT License
14 stars 6 forks source link

How do I compile this project? #1

Closed skyformat99 closed 7 years ago

skyformat99 commented 7 years ago

hi Want to try, how to compile it? thanks

skyformat99 commented 7 years ago

The following method failed: aclocal autoreconf -i automake ./configure

romuloceccon commented 7 years ago

autoreconf -i && ./configure && make should be enough, provided you have the dependencies installed (autoconf-archive and check). What error message do you get?

P.S.: I've added a "Contributing" section to the README file explaining how to compile.

skyformat99 commented 7 years ago

Success! thank you very much! This project is very, very cool ! ๑乛◡乛๑

skyformat99 commented 7 years ago

The following files are in the .libs folder: -rw-rw-r-- 1 123536 Jun 28 08:17 liblightmqtt.a lrwxrwxrwx 1 18 Jun 28 08:17 liblightmqtt.la -> ../liblightmqtt.la -rw-rw-r-- 1 976 Jun 28 08:17 liblightmqtt.lai lrwxrwxrwx 1 21 Jun 28 08:17 liblightmqtt.so -> liblightmqtt.so.0.0.0 lrwxrwxrwx 1 21 Jun 28 08:17 liblightmqtt.so.0 -> liblightmqtt.so.0.0.0 -rwxrwxr-x 1 100356 Jun 28 08:17 liblightmqtt.so.0.0.0

1) are these .a .so files in Release version? 2) liblightmqtt.a --> static library, liblightmqtt.so.0.0.0 --> dynamic library? 3) I built the broker using apollo (http://activemq.apache.org/apollo/), but failed with the pingpong test because user password was needed in apollo broker. can you add user & password support in example code?

romuloceccon commented 7 years ago

1) are these .a .so files in Release version?

It depends on the options you gave to configure. In my platform the default is -g -O2.

2) liblightmqtt.a --> static library, liblightmqtt.so.0.0.0 --> dynamic library?

Correct!

3) I built the broker using apollo (http://activemq.apache.org/apollo/), but failed with the pingpong test because user password was needed in apollo broker. can you add user & password support in example code?

Later I'm going to add some command line arguments in the examples to configure client credentials. Meanwhile you can use something like the following to make your tests. Let me know if you have any problem!

diff --git a/examples/pingpong.c b/examples/pingpong.c
index 1c5248e..8c960dc 100644
--- a/examples/pingpong.c
+++ b/examples/pingpong.c
@@ -101,6 +101,9 @@ void run(const char *address, unsigned short port)
     lmqtt_message_callbacks_t message_callbacks;
     lmqtt_client_buffers_t buffers;

+    static char *user = "myusr";
+    static char *password = "mypwd";
+
     socket_fd = socket_open(address, port);
     if (socket_fd == -1) {
         fprintf(stderr, "socket_open failed\n");
@@ -142,6 +145,10 @@ void run(const char *address, unsigned short port)
     connect_data.clean_session = 1;
     connect_data.client_id.buf = id;
     connect_data.client_id.len = strlen(id);
+    connect_data.user_name.buf = user;
+    connect_data.user_name.len = strlen(user);
+    connect_data.password.buf = password;
+    connect_data.password.len = strlen(password);

     lmqtt_client_connect(&client, &connect_data);
skyformat99 commented 7 years ago

Thank you for your reply. Modify the code according to your prompt, the connection is ok, but there are errors in the ping pong test.

/home/mqtt/lightmqtt/build/examples$ ./pingpong -h 192.168.2.55 -p 61613 -i pong -t ping pong (0): st client: error

/home/mqtt/lightmqtt/build/examples$ ./pingpong -h 192.168.2.55 -p 61613 -i ping -t pong -m test ping (0):

romuloceccon commented 7 years ago

Ok. I'll try the examples using the Apollo broker later this week and find out the problem. Thanks for the feedback.

romuloceccon commented 7 years ago

@skyformat99, the issue you experienced was due to an incorrect implementation of the MQTT 3.1.1 spec regarding the handling of QoS 0 messages. It's now fixed in commit b9da4109bbe307f6c99fba2ae7f2b7bdfec41e1b.

Incidentally, the bug became evident because the Apollo broker also seems to not follow the specs correctly: even when receiving QoS 2 messages it forwards them using QoS 0.

skyformat99 commented 7 years ago

thanks,I will try again。😃

skyformat99 commented 7 years ago

@romuloceccon Thank you. That's ok. btw, Can you add automatic connect function? For instance, When the broker restarts, ping/pong test cannot auto connect to the broker server.

like as: typedef void (lmqtt_client_on_disconnect_t)(void , lmqtt_connect_t *, int);

skyformat99 commented 7 years ago

In addition, can use macro definitions in code? thanks.

/**

romuloceccon commented 7 years ago

@skyformat99, could you please open separate tickets for those requests?

skyformat99 commented 7 years ago

ok, close it.