Option to cache resolved host addresses

Hi! I develop Android XMPP client using Smack.

It is popular use case for Android devices to reconnect often. I use existing XMPPTCPConnection to reconnect.

But DNS resolving (populateHostAddresses method) called every time. It looks a little overhead, but the main problem for me is that it hangs on some Androids (6+). I suspect doze mode (but buttery optimization is disabled for application).

I tried to connect to ip address directly and it worked much better. So I want to cache hosts addresses resolved in populateHostAddresses method.

For now I want to try to oveload this method and do not resolve host addresses if they are not empty. May be add some interval not to call it too often.

Is it possible to have similar behavior (optionally) in Smack?

Thanks for any help!

Hi! I develop Android XMPP client using Smack.

Hu? Why did you start to introduce yourself. You are well known in this forum.

I suspect doze mode (but buttery optimization is disabled for application).

Unlikely. Especially if you already whitelisted the app.

So I want to cache hosts addresses resolved in populateHostAddresses method.

All three supported DNS resolvers by Smack, that is JavaX, dnsjava and MiniDNS, should already cache the result (but not persistent, see e.g. Add a persistent cache · Issue #49 · rtreffer/minidns · GitHub ).

So yes, populateHostAddresses() may be called every time, but the involved resolvers should use their cache. Are you positive that there are DNS queries send over the wire for resource records which should have been cached?

Thanks, Flow, I think you’re right.

I have problems this doze mode even with battery white list (Motorolla using Android 6), but wake lock was not used.