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?
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.