What is the best MQTT Client for Pub and Sub?

I'm using the ESP8266 and ESP32 modules. I desire to both publish and subscribe to MQTT from a single module. I also have a desire to use encrypted communication. I prefer to pub/sub at QOS 0, 1, and 2 if possible.

I originally started with the adafruit library as it was the first hit I came across. I noticed that subs sit in a loop and to publish you have to break out of the loop. The default is 5 seconds which is too low of a resolution to deal with a publish for when a switch is connected. I lowered the timer to .5 seconds but polling that often causes a crash (not sure why yet).

Instead of polling I desire to operate on a callback or interrupt for subscriber messages. What lib. for MQTT do you recommend?

One more requirement, I need to publish and subscribe to multiple topics.

I noticed that subs sit in a loop

Say what? Request to subscribe to a topic may be queued, but that's generally OK, because you only subscribe once, on startup.

and to publish you have to break out of the loop.

This doesn't make sense. You need to post your code, and a link to the library you are using.

The default is 5 seconds

The default what? Ice cream flavor?

I lowered the timer to .5 seconds but polling that often causes a crash (not sure why yet).

You lowered the actual whatever to 5, from the default of 5? Not much of a change, was it?

What, exactly, crashed, when you did that?

It REALLY looks like the problem is your code or your MQTT server, not the library.

PaulS:
Say what? Request to subscribe to a topic may be queued, but that's generally OK, because you only subscribe once, on startup.
This doesn't make sense. You need to post your code, and a link to the library you are using.
The default what? Ice cream flavor?
You lowered the actual whatever to 5, from the default of 5? Not much of a change, was it?

What, exactly, crashed, when you did that?

It REALLY looks like the problem is your code or your MQTT server, not the library.

I should have replied more clearly. I started with the adafruit MQTT lib as documented here.

Reading a subscription update within the library is not a callback, rather you poll as seen in line 102 here:

I believe I was using that example as well when I modified the polling from 5000 ms to 500ms (5 seconds to 0.5 seconds). This is when the ESP module panic'd. I didn't grab the dump as I didn't want to debug a library that looked unusable for a single client doing both pub and sub. Notice my original post stated this as .5 vs. 0.5. I suppose this isn't a default, it's "user driven" but the example code provided a 5 second window.

I have since moved to a different MQTT library (https://pubsubclient.knolleary.net/) that implements subscription updates as callbacks. I haven't checked over an encrypted connection but this is allowing me to do what I want in the short term. This library does not support QOS 2 unfortunately (but it sounds like a limitation of data persistence within the module).

MQTT isn't a traditional client/server model per say. It's a pub/sub model with clients and a broker (server). In this case I'm using a mosquitto broker which works fine.

Notice my original post stated this as .5 vs. 0.5.

Actually, it looked to me like a spot on the laptop screen. Floating point values need to ALWAYS have a digit before the decimal point, even if the digit is 0.