NWParemeters.requiredLocalEndpoint is ignored in VisionOS

I have a an application that incorporates a RTCP client to communicate with a local networked device. The device's RTCP implementation requires that the local RTCP port be 6970 even for the initial outbound connection. I have an implementation that is working just fine on macOS and iOS, but I when I port this to visionOS, I see that the local connection is ignoring my .requiredLocalEndpoint specification and choosing a random port (I can see this is happening in Wireshark via the VisionOS simulator.)

let remoteRtcpEndpoint = NWEndpoint.hostPort(host: NWEndpoint.Host(remoteRTCPAddress), port: NWEndpoint.Port(rawValue: remoteRTCPPort)!)

let rtcpParameters = NWParameters.udp
let localEndpoint = NWEndpoint.hostPort(host: NWEndpoint.Host("0.0.0.0"), port: NWEndpoint.Port(rawValue: localRTPPort)!)
Self.logger.info("Starting rtcp with local port \(localRTPPort), remote address \(remoteRTCPAddress), endpoint \(String(describing: localEndpoint))")
rtcpParameters.requiredLocalEndpoint = localEndpoint
rtcpParameters.allowLocalEndpointReuse = true

remoteRtcpConnection = NWConnection(to: remoteRtcpEndpoint, using: rtcpParameters)
remoteRtcpConnection.start(queue: .global())

And here's the code that sends the command.


            remoteRtcpConnection.send(content: RtcpPacket.vdly(delayMs: HUGE_FIXED_VDLY_MS).packet(), completion: .contentProcessed({ error in
                if let error = error {
                    Self.logger.warning("Error sending VDLY packet \(error)")
                    continuation.resume(throwing: error)
                } else {
                    Self.logger.debug("VDLY Sent \(self.HUGE_FIXED_VDLY_MS)")
                    continuation.resume(returning: ())
                }
            }))

If this is a known limitation of the Network framework, should I revert to BSD sockets or something? How can I work around this? Additionally, I don't have a VisionOS device, so I am using the simulator, could this be a problem with the simulator's network bridge?

Answered by msdrigg in 782608022

Unfortunately I don't have a real device to confirm and won't have the funds to get one anytime soon, but your asking did make me recheck and I found some interesting behavior.

  • Working on iOS Real Device iPad, iPhone (Uses port 6970)
  • Working on macOS Real Device (Uses port 6970)
  • Not working on iOS Simulator (Uses random port)
  • Not working on VisionOS Simulator (Uses random port)

I thought I had already checked and it worked on iOS simulator, but I guess I mis-remembered. I'll consider this closed for now until I get a VisionOS bug report saying that it's an issue there on real devices.

Well, that’s weird. Your are correct that visionOS and iOS should behave the same when it comes to this sort of thing.

Does the problem reproduce on a real device?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

Unfortunately I don't have a real device to confirm and won't have the funds to get one anytime soon, but your asking did make me recheck and I found some interesting behavior.

  • Working on iOS Real Device iPad, iPhone (Uses port 6970)
  • Working on macOS Real Device (Uses port 6970)
  • Not working on iOS Simulator (Uses random port)
  • Not working on VisionOS Simulator (Uses random port)

I thought I had already checked and it worked on iOS simulator, but I guess I mis-remembered. I'll consider this closed for now until I get a VisionOS bug report saying that it's an issue there on real devices.

Hmmm, that seems like a bug in the simulator. I’d appreciate you filing it as such. Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Submitted as FB13686829

NWParemeters.requiredLocalEndpoint is ignored in VisionOS
 
 
Q