Cannot interrupt connecting socket

Hlelo I am using smack over android

android introduced doze mode due to which connection to server is lost same is for some phones like mi redmi has their own firewall which restricts background connection only way to connect is gcm or fcm msg which lets open connection to server for very limited time.

If smack is in connecting mode like socket.connnect(server, timeout) which has default timeout of 30000 and if fcm is recvd during this time of connection I am not able to suspend this connection until it timeouts leading late delivery of messages

Can someone please help in solving this problem

Thanks

Jeet

AFAIK Socket.connect() is not interruptible, but Smack lets you configure the timeout: ConnectionConfiguration.setConnectTimeout().