Well, this is not the answer for the UDP session behaviour on iOS 12. As posted at the beginning of this thread on iOS 12 if the server was stopped there will be an error occur on the UDP session's read handler. The question is why doesn't iOS 14 do the same magic as iOS 12?
Post
Replies
Boosts
Views
Activity
I tried with the VPN tunnel using a TCP connection with NWTCPConnection on iOS 14.7.1. If I stop the server then on the client side an error Error Domain=NSPOSIXErrorDomain Code=57 "Socket is not connected" will instantly show up in the console log.
On iOS 14 if the server application was stopped the client just acts as it doesn't detect anything from the server-side, it's understandable since the UDP session is stateless.
On iOS 12 if the server application was stopped the client-side can give out an error message on the UDP session read handler which I think is great. I don't know how it works but it seems this mechanism is not provided on iOS 14.
Thanks Matt.
As I observed on iOS 14.7.1 when the VPN tunnel (which is a UDP session) is established if I stop the VPN server, the isViable is still true, and state is still ready, and the packetFlow keeps reading packets and also can writeMultipleDatagrams without any problems. And this status can last for a long time, I never see it stop. It seems the UDP session's read handler is just not called.
But once if I restart the VPN server's service, then it will give out errors like
Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused"
Error Domain=NSPOSIXErrorDomain Code=89 "Operation canceled"
It seems not always to be able to reproduce this issue. I only observed it with the youtube application sometimes. Most of the time it just runs perfectly without any problems. Sometimes when I open a new youtube video this issue happens.
The Xcode shows the memory used by the NE is always lower than 5MB.
And I did a packet capture. When the Message too long error happens all the packets length are no more than 1500.
I also logged the maximumDatagramLength of the UDP session, it's 1452 on the WiFi network. On the Cellular network it's 1402.