Hello, We are facing an issue with performing a DTLS handshake when our iOS application is in the background. Our app (Vocera Collaboration Suite – VCS) uses secure DTLS-encrypted communication for incoming VoIP calls. Problem Summary: When the app is in the background and a VoIP PushKit notification arrives, we attempt to establish a DTLS handshake over our existing socket. However, the handshake consistently fails unless the app is already in the foreground. Once the app is foregrounded, the same DTLS handshake logic succeeds immediately. Key Questions: Is performing a DTLS handshake while the app is in the background technically supported by iOS? Or is this an OS-level limitation by design? If not supported, what is the Apple-recommended alternative to establish secure DTLS communication for VoIP flows without bringing the app to the foreground? Any guidance or clarification from Apple engineers or anyone who has solved a similar problem would be greatly appreciated. Thank you.
The general rule for networking in the background on iOS is that everything works as long as your process is running. Once your process gets suspended, you start running into edge cases.
TN2277 Networking and Multitasking talks about this idea, although it’s somewhat out of date. Specifically, I now talk about connections being defuncted rather than using the older socket resource reclaim terminology, because Network framework supports a user-space networking stack that doesn’t involve sockets.
However, it sounds like you’re using BSD Sockets directly, in which case TN2277 is still as relevant as it ever was. Specifically:
we attempt to establish a DTLS handshake over our existing socket
It’s likely that this socket was defuncted when your app was suspended in the background, and thus the issue isn’t with DTLS per se, but rather with networking proper.
If you open a network connection in this situation, does that work?
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"