I'm sorry to hear you're experiencing the "Publisher pc state failed" error. This message means that the publisher's peer connection ran into a problem during a WebRTC session, which can sometimes happen because of network hiccups, ICE negotiation issues, or longer connectivity interruptions.
Let’s walk through some steps together to help you troubleshoot and hopefully resolve this:
1.
Run Connection Diagnostics: Try using the LiveKit Connection Test utility. It checks WebSocket, WebRTC, and TURN server connectivity. Also, please make sure your network allows WebRTC traffic on UDP ports 50000-60000 and TURN server access on ports 3478 and 5349.
2.
Implement Reconnection Logic: The SDK has built-in reconnection features that can help handle peer connection failures. You can monitor connection states and have the system reconnect automatically when needed.
3.
ICE Restart: Restarting ICE connections can often clear up these issues. The SDK provides ways to trigger ICE restarts programmatically, which can be very helpful.
4.
Adjust Timeouts: Sometimes, increasing connection timeouts in your app settings can make a difference, especially if your network is a bit slow or unstable.
5.
Monitor and Log Errors: Setting up error monitoring to log connection state changes and failures can give you valuable insights for debugging.
If you still face issues after these steps, it might be due to network restrictions. In that case, it could be helpful to check with your IT team about whitelisting LiveKit domains and ports, or try temporarily disabling VPNs to see if that improves the connection.
Sources:
livekit/src/rtc_engine/mod.rs |
Diagnosing Connection Errors with Connection Test Utility |
lib/src/core/engine.dart |
src/room/RTCEngine.ts