Async MQTT authentication (using libcurl)

Check out the example plugin for async authentication using libcurl.

Asynchronous calls are calls that don’t block your program while waiting for a response. Instead of waiting for a response to a network request (for instance), you will initiate the request and check for a result later. If you don’t do this asynchronously for a network request that takes 500 ms, the thread executing the request will block for 500 ms, which is easily 1.5 billion CPU cycles wasted.

In the case of this example plugin, we ask an HTTP server to authenticate a connecting client, and tell FlashMQ to continue with its event loop until there is a response. This will allow us to have thousands of outstanding authentication requests without blocking FlashMQ.

Of course, it’s (likely) still better if you can load all authentication data in memory and perform the authentication locally. But, if you do have to external communication, the async interface is the way to go.

You Might Also Like