UDP CFSocket stops transmitting data after four packets.

Hi,

I have a simple query/response iPhone application which I developed over a year ago. It gets a key from the user, creates a UDP CFSocketRef with a Data callback and transmits the data to the server. When the response is received, it invalidates and releases the socket and displays the response. The socket is created new for each query.


My company wants to investigate using the Apple Watch with the app, which requires a later iPhone, ios 8+ and a new xcode. I acquired these things and decided that I would take the opportunity to update the app with later technologies such as Storyboards, and "improve" the code.


While testing the new app, I encountered a strange problem. It will perform exactly four queries perfectly. On the fifth query, while everything appears fine in the debugger, no data is transmitted from the phone. The sendto function returns 11, the size of the request. The profiler shows that the packet has been sent, but according to a network analyzer, no data appears on the network.


In order to determine if my "improvements" were to blame, I built the original app in the new environment and ran it on the iPhone 5. It had the same problem. I ran it on the original iPhone 4 with IOS 7. It exhibited the same behavior, after four queries no more data is transmitted. The original app built with the earlier xcode (4?) on the iPhone 4 continues to work as it always has.


I seem to have run into something in the CFNetwork framework that has changed, or is different in some way I don't know about.


Can anyone shed any light?


Thanks,

Ned

Answered by nedsnow in 25820022

OK, looks like it's not my code after all. :-) A VPN is required to access the server. We normally use the F5 Edge Client as the VPN. When I change to the Cisco VPN client, the app works as expected.Now I just need to find out why the F5 VPN doesn't. :-(


Regards,

Ned

I use the UDP communication in a my App with iOS7 and 8 without problems... I have problem when I try to send UDP message from the phone when the App in in beckgroud... this is because when the Phone is locked all UDP socket are closed by the OS.

Weird.

I usually tackle problems like this by simplifying things:

  • rip out chunks of potentially worrisome code until things start to work, or

  • write a simple test app and add code to that until you can replicate the problem

It's safe to assume that UDP works on iOS, so this bug is very likely to be in your code, or in how your code is using CFSocket.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

It gets weirder. I have discovered that if I wait what seems to be exactly 30 seconds after receiving the timeout on the fifth query, I can do four more queries.


I absolutely agree that the problem has to be in my code. Your suggestion is essentially my usual approach. I was hoping that something might be obvious to someone who could give me a clue.


Thanks for your attention.

Accepted Answer

OK, looks like it's not my code after all. :-) A VPN is required to access the server. We normally use the F5 Edge Client as the VPN. When I change to the Cisco VPN client, the app works as expected.Now I just need to find out why the F5 VPN doesn't. :-(


Regards,

Ned

UDP CFSocket stops transmitting data after four packets.
 
 
Q