Hello, I am using libcurl for receiving mqtt data (subscribe) with following configuration:
curl_easy_setopt( g_curl, CURLOPT_VERBOSE, 0 ); /* set verbosity */ curl_easy_setopt( g_curl, CURLOPT_URL, buf ); /* Set the URL/path */ curl_easy_setopt( g_curl, CURLOPT_PORT, g_port ); /* Set the port */ curl_easy_setopt( g_curl, CURLOPT_DEFAULT_PROTOCOL, "mqtt"); /* if URL misses scheme */ curl_easy_setopt( g_curl, CURLOPT_NOPROGRESS, 1); /* turn off progress meter */ curl_easy_setopt( g_curl, CURLOPT_TIMEOUT, 30); /* connection timeout */ curl_easy_setopt( g_curl, CURLOPT_WRITEFUNCTION, write_data); curl_easy_setopt( g_curl, CURLOPT_WRITEDATA, user_data); cc = curl_easy_perform(g_curl); curl_easy_cleanup(g_curl); if (cc != CURLE_OK) { fprintf( stderr, "could not get MQTT data (%d)\n", cc ); return sz; } Here is what my write_data() looks like: size_t write_data(char *in_data, size_t size, size_t nmemb, void *user_data){ fprintf( stdout, "entered write_data\n"); fprintf( stdout, "Received msg: %s\n", in_data+2); //perform data operations return nmemb; } Problem: I receive the data in my write_data function, but the curl_easy_perform() call in the main function does not return. It only returns after the timeout is over, regardless of how many times the data is published by the MQTT broker and received by the app. Is this expected behavior? How can I make curl_easy_perform return? PS: If there is any sample code for libcurl that uses MQTT, please point me in that direction. Best regards, Hamza -- Unsubscribe: https://lists.haxx.se/listinfo/curl-library Etiquette: https://curl.se/mail/etiquette.html