Bonjour Browser / Listener Connections frequently Fail

I've been working through some issues here attempting to migrate away from the MultiPeer Connectivity following the guidance in here, Moving from Multipeer Connectivity to Network Framework, and implementing a home-grown solution using NWBrowser and NWListener and NWConnections.

I feel like I am 95% of the way there, but am experiencing an issue where my connection attempts seem to fail about 50% of the time.

If I have two nodes say, one a physical iPad, and one a simulator on my Mac. I can start them both up, and they are both discovered with Bounjour no problem. Sometimes the "connect" no problem. Othertimes however when I attempt to "connect" from one device to the other, I get failures. I'd say it's about 50/50 success - fail at this point.

The "dialing" device state enters "preparing" but never progesses past that, and on the "receiving end" I see

receive error: POSIXErrorCode(rawValue: 61): Connection refused

I'm at my wits end here with this, everything else in my migration I think is done...just need some insights maybe on potential causes for that error...

Further testing here...I think this might be related to using a physical iPad along with an Xcode Simulator. Both are connected to XCode debugger, so I can view the logs. However, if I test this with two physical iPads, it seems to work perfectly. Haven't managed to trigger a fail state yet.

Bonjour Browser / Listener Connections frequently Fail
 
 
Q