Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE-TCP doesn't work on FireFox (Only Chromium) #2125

Closed
maeln opened this issue Feb 16, 2022 · 6 comments
Closed

ICE-TCP doesn't work on FireFox (Only Chromium) #2125

maeln opened this issue Feb 16, 2022 · 6 comments

Comments

@maeln
Copy link

maeln commented Feb 16, 2022

Your environment.

What did you do?

We are streaming a single video (VP8) stream from a server using WebRTC with Pion. This server has a public address and can be reached on the internet. For this reason, we send host type candidate to our client. We don't have a TURN or STUN server as of right now.

Some client are in restricted network that block UDP. For this reason, we wan't to be able to propose TCP candidate to our client.
For this reason we added the following configuration to our server:

func createWebrtcPeerConnection() (*PeerConnection, error) {
	settingEngine := webrtc.SettingEngine{}

	if tcpListener != nil {
		settingEngine.SetNetworkTypes([]webrtc.NetworkType{
			webrtc.NetworkTypeUDP4,
			webrtc.NetworkTypeUDP6,
			webrtc.NetworkTypeTCP6,
			webrtc.NetworkTypeTCP4,
		})

		tcpMux := webrtc.NewICETCPMux(nil, tcpListener, 8)
		settingEngine.SetICETCPMux(tcpMux)
	}

	mediaEngine, err := createVP8MediaEngine()
	if err != nil {
		return nil, errors.Wrap(err, "cannot create peer connection")
	}

	api := webrtc.NewAPI(webrtc.WithMediaEngine(mediaEngine), webrtc.WithSettingEngine(settingEngine))

	[...]

	return nil
}

......

func ListenForTCPCandidates() error {
	if enableWerbrcTCP, ok := os.LookupEnv("ENABLE_WEBRTC_TCP_CANDIDATES"); !ok && enableWerbrcTCP != "1" {
		log.Println("WebRTC TCP candidates disabled, no TCP listener started.")
		return nil
	}

	var tcpPort = 8001
	if tcpPortRaw, ok := os.LookupEnv("WEBRTC_TCP_PORT"); ok {
		var err error
		if tcpPort, err = strconv.Atoi(tcpPortRaw); err != nil {
			return fmt.Errorf("WEBRTC_TCP_PORT should be an int, \"%s\" given", tcpPortRaw)
		}
	}

	var err error
	tcpListener, err = net.ListenTCP("tcp", &net.TCPAddr{
		Port: tcpPort,
	})

	if err != nil {
		return err
	}

	log.Printf("Listening for WebRTC ICE TCP at %s\n", tcpListener.Addr())
	return nil
}

The main consumer/client is a Unity application running on a phone. It is using the Unity package for WebRTC which is based on Google's libwebrtc. This client, for testing purposes, will filter out all non-TCP candidate (and we have our own protocol to exchange candidate).

After adding the previously mentioned line to the server, our client does receive TCP candidate. For example, this is a candidate that we receive :

candidate:1598569939 1 tcp 2124414975 169.254.204.172 8001 typ host tcptype passive

When the server are in the same local network (10.1.0.0/24 in the pcap file), it works. The server send the candidate, the client add them, a connection is made and completed and the video stream start and is displayed correctly. The only issue is that when the client disconnect, the server seem to still try to write to a pipe and display a lot of I/O error.

On the other end, when we try connecting through the internet (the server being hosted on a cloud service and the client using a home internet connection), the state of the ICE connection stays at "Checking" and the server never start to send video frame to the client.

There is no firewall that would block TCP (or UDP) between the client and the server.

What did you expect?

We expected the connection to be completed and video frame to be sent, no matter the network and the protocol used. As of now TCP+Internet does not seem to work.
UDP+Internet is working.

Our Findings

After looking further, we notice something in the packet capture:
After adding the ICE candidate sent by the server, the client send a STUN Binding Request to the Pion-based server. The server never seem to answer this request. But right after, the server do send Binding Request to the client, and the client respond. After this, the connection seems established and the video start streaming.

As you will be able to see, when not on the same local-network, this doesn't happen. The client still send a request first, the serve still ignore it, but the server never send a Request Binding to the client.

For this reason, we are supposing an issue with the STUN protocol.

Using two Pion peer

We also have a Pion-based peer/client. So we tried to make the server only serve TCP candidate by removing webrtc.NetworkTypeUDP4 & webrtc.NetworkTypeUDP6 from the setNetworkTypes in the setting engine.

When this is the case, both peer refuse to connect to one another, even when they are in the same local-network (or even on the same machine.

Here is the logs with ice tracing info. For the server :

GOROOT=/usr/local/opt/go/libexec #gosetup
GOPATH=/Users/maeln/go #gosetup
/usr/local/opt/go/libexec/bin/go build -o /private/var/folders/yp/j2scrhfn087032gvsvxh7vvw0000gn/T/GoLand/___media_server /Users/maeln/Work/crane/video/server/cmd/cmd.go #gosetup
/private/var/folders/yp/j2scrhfn087032gvsvxh7vvw0000gn/T/GoLand/___media_server
2022/02/16 12:07:57 Listening on :7001
2022/02/16 12:07:57 Listening for WebRTC ICE TCP at [::]:8001
2022/02/16 12:08:11 New client connected: 10.1.0.152:52422
2022/02/16 12:08:11 Got request from client &{362405b5-80e2-4bcd-90c2-5e417bb6683d 0xc00013c160 map[] map[close_room:{false close_room 0x16a2960} create_room:{false create_room 0x16a2900} identify:{true identify 0x16a28a0} register_inputs:{false register_inputs 0x16a29c0} set_room_inputs_paused:{false set_room_inputs_paused 0x16a2a80} start_recording:{false start_recording 0x16a2ae0} stop_recording:{false stop_recording 0x16a2b40} unregister_inputs:{false unregister_inputs 0x16a2a20} webrtc_candidate:{false webrtc_candidate 0x16a2ba0}] 0xc000026208 false}: identify
2022/02/16 12:08:11 Received message with method identify
2022/02/16 12:08:11 Got request from client &{362405b5-80e2-4bcd-90c2-5e417bb6683d 0xc00013c160 map[] map[close_room:{false close_room 0x16a2960} create_room:{false create_room 0x16a2900} identify:{true identify 0x16a28a0} register_inputs:{false register_inputs 0x16a29c0} set_room_inputs_paused:{false set_room_inputs_paused 0x16a2a80} start_recording:{false start_recording 0x16a2ae0} stop_recording:{false stop_recording 0x16a2b40} unregister_inputs:{false unregister_inputs 0x16a2a20} webrtc_candidate:{false webrtc_candidate 0x16a2ba0}] 0xc000026208 true}: create_room
2022/02/16 12:08:11 Received message with method create_room
2022/02/16 12:08:11 Created room TEST
2022/02/16 12:08:16 Got request from client &{362405b5-80e2-4bcd-90c2-5e417bb6683d 0xc00013c160 map[] map[close_room:{false close_room 0x16a2960} create_room:{false create_room 0x16a2900} identify:{true identify 0x16a28a0} register_inputs:{false register_inputs 0x16a29c0} set_room_inputs_paused:{false set_room_inputs_paused 0x16a2a80} start_recording:{false start_recording 0x16a2ae0} stop_recording:{false stop_recording 0x16a2b40} unregister_inputs:{false unregister_inputs 0x16a2a20} webrtc_candidate:{false webrtc_candidate 0x16a2ba0}] 0xc000026208 true}: register_inputs
2022/02/16 12:08:16 Received message with method register_inputs
ice INFO: 2022/02/16 12:08:16 Listening TCP on [::]:8001
pc INFO: 2022/02/16 12:08:16 signaling state changed to have-remote-offer
ice TRACE: 12:08:16.241302 agent.go:565: Set selected candidate pair: 
ice DEBUG: 12:08:16.241389 agent.go:451: Started agent: isControlling? false, remoteUfrag: "RCvBBJaeCyVIsbmH", remotePwd: "YpdrPHhmftQePbDtqbQKlGvXsfcfJlwP"
pc INFO: 2022/02/16 12:08:16 signaling state changed to stable
ice INFO: 2022/02/16 12:08:16 Setting new connection state: Checking
ice TRACE: 12:08:16.241471 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:16 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
pc INFO: 2022/02/16 12:08:16 ICE connection state changed: checking
ice DEBUG: 12:08:16.241625 gather.go:175: GetConn by ufrag: rkVOZjthuhcEzBnt
ice DEBUG: 12:08:16.241709 gather.go:175: GetConn by ufrag: rkVOZjthuhcEzBnt
ice TRACE: 12:08:16.241734 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:16 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
2022/02/16 12:08:16 Sending candidate: candidate:3278913027 1 tcp 2124414975 10.1.0.152 8001 typ host tcptype passive
2022/02/16 12:08:16 Sending candidate: candidate:1598569939 1 tcp 2124414975 169.254.204.172 8001 typ host tcptype passive
ice TRACE: 12:08:16.241905 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:16 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:16.442037 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:16 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:16.642166 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:16 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:16.843341 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:16 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:17.044498 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:17 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:17.245674 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:17 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:17.446635 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:17 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:17.647221 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:17 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:17.847700 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:17 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:18.048242 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:18 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:18.249424 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:18 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:18.450553 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:18 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:18.651662 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:18 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:18.851881 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:18 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:19.052057 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:19 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:19.252542 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:19 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:19.453649 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:19 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:19.654483 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:19 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:19.854727 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:19 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:20.055729 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:20 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:20.256872 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:20 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:20.457285 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:20 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:20.657435 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:20 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:20.857970 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:20 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:21.058907 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:21 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:21.259580 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:21 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:21.459946 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:21 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:21.660113 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:21 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:21.860294 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:21 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:22.060691 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:22 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:22.261855 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:22 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:22.462607 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:22 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:22.663119 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:22 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:22.863294 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:22 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:23.063764 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:23 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:23.264766 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:23 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:23.465842 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:23 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:23.666357 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:23 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:23.866559 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:23 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:24.067695 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:24 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:24.268206 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:24 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:24.468825 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:24 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:24.669035 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:24 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:24.869941 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:24 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:25.071247 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:25 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:25.271803 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:25 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:25.472772 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:25 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:25.673895 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:25 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:25.874540 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:25 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:26.074638 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:26 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:26.275127 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:26 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:26.475391 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:26 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:26.676275 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:26 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:26.876732 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:26 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:27.076886 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:27 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:27.278058 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:27 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:27.478274 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:27 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:27.679308 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:27 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:27.880453 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:27 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:28.080668 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:28 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:28.281813 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:28 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:28.482759 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:28 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:28.683633 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:28 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:28.884516 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:28 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:29.084953 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:29 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:29.285183 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:29 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:29.485608 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:29 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:29.686026 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:29 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
2022/02/16 12:08:29 [ROOM TEST] closing room
2022/02/16 12:08:29 [INPUT 0x8020000005ac8514] closing input
ice INFO: 2022/02/16 12:08:29 Setting new connection state: Closed
pc INFO: 2022/02/16 12:08:29 peer connection state changed: closed
2022/02/16 12:08:29 [ROOM TEST] room closed
pc WARNING: 2022/02/16 12:08:29 Failed to start manager: connecting canceled by caller
ice INFO: 2022/02/16 12:08:29 Error accepting connection: accept tcp [::]:8001: use of closed network connection
pc INFO: 2022/02/16 12:08:29 ICE connection state changed: closed
2022/02/16 12:08:29 [CLIENT 362405b5-80e2-4bcd-90c2-5e417bb6683d] ICE connection state changed: closed

Process finished with the exit code 0

And here is the log for the client:

GOROOT=/usr/local/opt/go/libexec #gosetup
GOPATH=/Users/maeln/go #gosetup
/usr/local/opt/go/libexec/bin/go build -o /private/var/folders/yp/j2scrhfn087032gvsvxh7vvw0000gn/T/GoLand/___media_client /Users/maeln/Work/crane/video/client/cmd/cmd.go #gosetup
/private/var/folders/yp/j2scrhfn087032gvsvxh7vvw0000gn/T/GoLand/___media_client
2022/02/16 12:08:16 Detected media devices:
2022/02/16 12:08:16     - 0x8020000005ac8514 [db642bf9-84eb-4ae1-9e45-85465d02e3cb]
2022/02/16 12:08:16             - 640x480@0 (NV12)
2022/02/16 12:08:16             - 640x480@0 (YUY2)
2022/02/16 12:08:16             - 1280x720@0 (NV12)
2022/02/16 12:08:16             - 1280x720@0 (YUY2)
2022/02/16 12:08:16 Using media size 640x480
2022/02/16 12:08:16 camera feed added: Track bd1f5f87-2c26-41e9-bf41-e34dddfad652 | 0x8020000005ac8514
2022/02/16 12:08:16 Connecting to machine: ws://localhost:7000/video
ice TRACE: 12:08:16.236955 agent.go:565: Set selected candidate pair: 
pc INFO: 2022/02/16 12:08:16 signaling state changed to have-local-offer
ice DEBUG: 12:08:16.237411 gather.go:175: GetConn by ufrag: RCvBBJaeCyVIsbmH
2022/02/16 12:08:16 Sending candidate: candidate:3574289981 1 udp 2130706431 fd02:c6ab:e78c:0:1837:2710:7ff5:8de0 50517 typ host
2022/02/16 12:08:16 Sending candidate: candidate:2122534883 1 udp 2130706431 10.1.0.152 60853 typ host
ice DEBUG: 12:08:16.237624 gather.go:175: GetConn by ufrag: RCvBBJaeCyVIsbmH
ice DEBUG: 12:08:16.237701 gather.go:175: GetConn by ufrag: RCvBBJaeCyVIsbmH
2022/02/16 12:08:16 Sending candidate: candidate:3803925555 1 udp 2130706431 169.254.204.172 64128 typ host
pc INFO: 2022/02/16 12:08:16 signaling state changed to stable
2022/02/16 12:08:16 Got request from client &{3d1f2613-ae24-40ee-8d97-6030bf03efac 0xc0000caf20 map[] map[webrtc_candidate:{false webrtc_candidate 0x436d920}] 0xc000027b90 true}: webrtc_candidate
2022/02/16 12:08:16 Received message with method webrtc_candidate
2022/02/16 12:08:16 ICE candidate reiceived: candidate:3278913027 1 tcp 2124414975 10.1.0.152 8001 typ host tcptype passive
2022/02/16 12:08:16 Got request from client &{3d1f2613-ae24-40ee-8d97-6030bf03efac 0xc0000caf20 map[] map[webrtc_candidate:{false webrtc_candidate 0x436d920}] 0xc000027b90 true}: webrtc_candidate
2022/02/16 12:08:16 Received message with method webrtc_candidate
2022/02/16 12:08:16 ICE candidate reiceived: candidate:1598569939 1 tcp 2124414975 169.254.204.172 8001 typ host tcptype passive
ice DEBUG: 12:08:17.865507 agent.go:451: Started agent: isControlling? true, remoteUfrag: "rkVOZjthuhcEzBnt", remotePwd: "JLEoGNCtfzRcxyicGqodTdUKrvZKxdPE"
ice INFO: 2022/02/16 12:08:17 Setting new connection state: Checking
pc INFO: 2022/02/16 12:08:17 ICE connection state changed: checking
ice TRACE: 12:08:17.865662 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:17 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:18.065961 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:18 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:18.266198 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:18 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:18.466574 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:18 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:18.667629 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:18 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:18.868169 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:18 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:19.068737 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:19 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:19.269046 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:19 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:19.470123 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:19 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:19.670951 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:19 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:19.871764 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:19 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:20.072071 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:20 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:20.273221 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:20 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:20.473415 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:20 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:20.674557 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:20 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:20.875544 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:20 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:21.076134 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:21 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:21.276868 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:21 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:21.477325 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:21 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:21.677530 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:21 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:21.878134 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:21 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:22.079373 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:22 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:22.280658 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:22 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:22.481422 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:22 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:22.681866 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:22 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:22.882136 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:22 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:23.083111 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:23 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:23.283604 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:23 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:23.484781 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:23 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:23.685787 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:23 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:23.886445 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:23 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:24.087459 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:24 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:24.288247 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:24 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:24.488486 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:24 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:24.689645 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:24 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:24.889841 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:24 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:25.091285 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:25 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:25.291682 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:25 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:25.492167 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:25 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:25.693049 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:25 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:25.893672 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:25 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:26.093771 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:26 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:26.294141 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:26 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:26.494985 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:26 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:26.695141 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:26 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:26.895473 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:26 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:27.095804 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:27 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:27.296945 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:27 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:27.497720 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:27 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:27.698018 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:27 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:27.898330 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:27 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:28.098802 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:28 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:28.299253 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:28 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:28.499880 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:28 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:28.701231 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:28 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:28.902404 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:28 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:29.102612 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:29 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:29.303088 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:29 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:29.503272 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:29 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice TRACE: 12:08:29.704062 agent.go:593: pinging all candidates
ice WARNING: 2022/02/16 12:08:29 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
2022/02/16 12:08:29 Stopping media client
2022/02/16 12:08:29 Closing camera feeds
2022/02/16 12:08:29 Closing peer connection
2022/02/16 12:08:29 track db642bf9-84eb-4ae1-9e45-85465d02e3cb ended with error: io: read/write on closed pipe
2022/02/16 12:08:29 Error while closing client (ignored): send on closed channel

Process finished with the exit code 0

Faithfully yours,
Maël

@davidzhao
Copy link
Member

This is because you are using a advertising a private address 169.254.204.172 for the TCP candidate. You'd want to use setNAT1To1IPs with your public IP address.

@maeln
Copy link
Author

maeln commented Feb 17, 2022

This was just an example. We have candidate with public address, sorry for the confusion.

I still tried to add the setNAT1To1IPs but no dice.

@Sean-Der
Copy link
Member

Hey @maeln

I wasn't able to reproduce this. I launched a EC2 instance in AWS and am running the ice-tcp example. The only modification I made is

diff --git a/examples/ice-tcp/main.go b/examples/ice-tcp/main.go
index 5f26156..dc3419b 100644
--- a/examples/ice-tcp/main.go
+++ b/examples/ice-tcp/main.go
@@ -42,6 +42,8 @@ func doSignaling(w http.ResponseWriter, r *http.Request) {
                tcpMux := webrtc.NewICETCPMux(nil, tcpListener, 8)
                settingEngine.SetICETCPMux(tcpMux)

+               settingEngine.SetNAT1To1IPs([]string{"18.216.219.191"}, webrtc.ICECandidateTypeHost)
+
                api := webrtc.NewAPI(webrtc.WithSettingEngine(settingEngine))
                if peerConnection, err = api.NewPeerConnection(webrtc.Configuration{}); err != nil {
                        panic(err)

You can access the demo at http://18.216.219.191:8080/

@maeln
Copy link
Author

maeln commented Feb 18, 2022

Hello @Sean-Der !

I tried your demo on my home internet connection and on my phone 4g connection and with both I get :

ICE Connection States
checking
failed

I recorded the communication with tcpdump, here are the captures (filtered to only the communication between the EC2 instance and me):

  • With the home internet connection: link
  • With the phone connection: link

Something interesting is that the STUN communication do seems to work because I see some Binding Success Response.
With my limited knowledge, I don't see where is the failure.

I also saved the about:webrtc from Firefox to have all the information : link. The first two test from the top are made from the phone connection and the last three from my home internet.

I realize that I failed to mention it but I did most of these test under MacOS with no change to the default firewall parameters.

I will work with my colleague to try to provide a minimal example of a client-server that replicate the issue.

@Sean-Der Sean-Der changed the title Cannot complete a connection using TCP-only in non-local network. ICE-TCP doesn't work on FireFox (Only Chromium) Feb 18, 2022
Sean-Der added a commit to pion/ice that referenced this issue Feb 20, 2022
TCPMux before would create one internal connection per ufrag. This could
cause remote IPv6 traffic to be dispatched to a local IPv4 handler (or
the inverse). The ice.Agent would then discard the traffic since a
candidate pair must be the same IP version.

This commit now creates two connections per ufrag. When requesting a
connection for a ufrag the user must specify if they want IPv4 or IPv6.

Resolves pion/webrtc#2125
Resolves pion/webrtc#1356
Sean-Der added a commit to pion/ice that referenced this issue Feb 20, 2022
TCPMux before would create one internal connection per ufrag. This could
cause remote IPv6 traffic to be dispatched to a local IPv4 handler (or
the inverse). The ice.Agent would then discard the traffic since a
candidate pair must be the same IP version.

This commit now creates two connections per ufrag. When requesting a
connection for a ufrag the user must specify if they want IPv4 or IPv6.

Resolves pion/webrtc#2125
Resolves pion/webrtc#1356
Sean-Der added a commit to pion/ice that referenced this issue Feb 21, 2022
TCPMux before would create one internal connection per ufrag. This could
cause remote IPv6 traffic to be dispatched to a local IPv4 handler (or
the inverse). The ice.Agent would then discard the traffic since a
candidate pair must be the same IP version.

This commit now creates two connections per ufrag. When requesting a
connection for a ufrag the user must specify if they want IPv4 or IPv6.

Resolves pion/webrtc#2125
Resolves pion/webrtc#1356
pionbot pushed a commit to pion/ice that referenced this issue Feb 21, 2022
TCPMux before would create one internal connection per ufrag. This could
cause remote IPv6 traffic to be dispatched to a local IPv4 handler (or
the inverse). The ice.Agent would then discard the traffic since a
candidate pair must be the same IP version.

This commit now creates two connections per ufrag. When requesting a
connection for a ufrag the user must specify if they want IPv4 or IPv6.

Resolves pion/webrtc#2125
Resolves pion/webrtc#1356
Sean-Der added a commit to pion/ice that referenced this issue Feb 21, 2022
TCPMux before would create one internal connection per ufrag. This could
cause remote IPv6 traffic to be dispatched to a local IPv4 handler (or
the inverse). The ice.Agent would then discard the traffic since a
candidate pair must be the same IP version.

This commit now creates two connections per ufrag. When requesting a
connection for a ufrag the user must specify if they want IPv4 or IPv6.

Relates to pion/webrtc#2125
Relates to pion/webrtc#1356
pionbot pushed a commit to pion/ice that referenced this issue Feb 21, 2022
TCPMux before would create one internal connection per ufrag. This could
cause remote IPv6 traffic to be dispatched to a local IPv4 handler (or
the inverse). The ice.Agent would then discard the traffic since a
candidate pair must be the same IP version.

This commit now creates two connections per ufrag. When requesting a
connection for a ufrag the user must specify if they want IPv4 or IPv6.

Relates to pion/webrtc#2125
Relates to pion/webrtc#1356
Sean-Der added a commit to pion/ice that referenced this issue Feb 21, 2022
TCPMux before would create one internal connection per ufrag. This could
cause remote IPv6 traffic to be dispatched to a local IPv4 handler (or
the inverse). The ice.Agent would then discard the traffic since a
candidate pair must be the same IP version.

This commit now creates two connections per ufrag. When requesting a
connection for a ufrag the user must specify if they want IPv4 or IPv6.

Relates to pion/webrtc#2125
Relates to pion/webrtc#1356
@Sean-Der
Copy link
Member

With FireFox I am not able to connect when Pion is the controlled agent.

  • FireFox sends a binding request with UseCandidate. Pion creates a peer reflexive candidate + candidate pair
  • Pion sends a binding request (to validate the candidate)
  • FireFox sends another binding request with UseCandiate. Pion hasn't gotten a response to it's binding request yet and ignores (candidate pair isn't valid yet)
  • FireFox responds with Binding Success. Pion marks candidate pair as valid.

If FireFox sent another Binding Request everything would go to connected, not sure why it doesn't. I have attached the pcap here. You can reproduce at http://18.216.219.191:8080/ it is just running https://github.com/pion/webrtc/tree/master/examples/ice-tcp

I filed a bug with FireFox, waiting to hear back. https://bugzilla.mozilla.org/show_bug.cgi?id=1756460

Sean-Der added a commit to pion/ice that referenced this issue Feb 21, 2022
A controlled Agent would discard incoming Binding Requests if it didn't
cause the pair to be selected. For UDP Candidate this would be
interpreted as packet loss. For TCP Candidates not responding with a
Binding Success could be interpreted as a failure.

Firefox's ICE Agent would disconnect TCP Candidates because of this
behavior.

Resolves to pion/webrtc#2125
Resolves to pion/webrtc#1356
See https://bugzilla.mozilla.org/show_bug.cgi?id=1756460
Sean-Der added a commit to pion/ice that referenced this issue Feb 21, 2022
A controlled Agent would discard incoming Binding Requests if it didn't
cause the pair to be selected. For UDP Candidate this would be
interpreted as packet loss. For TCP Candidates not responding with a
Binding Success could be interpreted as a failure.

Firefox's ICE Agent would disconnect TCP Candidates because of this
behavior.

Resolves to pion/webrtc#2125
Resolves to pion/webrtc#1356
See https://bugzilla.mozilla.org/show_bug.cgi?id=1756460
Sean-Der added a commit to pion/ice that referenced this issue Feb 22, 2022
A controlled Agent would discard incoming Binding Requests if it didn't
cause the pair to be selected. For UDP Candidate this would be
interpreted as packet loss. For TCP Candidates not responding with a
Binding Success could be interpreted as a failure.

Firefox's ICE Agent would disconnect TCP Candidates because of this
behavior.

Resolves to pion/webrtc#2125
Resolves to pion/webrtc#1356
See https://bugzilla.mozilla.org/show_bug.cgi?id=1756460
@Sean-Der
Copy link
Member

ICE-TCP now works on FireFox. Getting this to work required fixing two distinct issues.

Make TCPMux IPv6 Aware

The TCPMux before would create one virtual candidate, and then pass all traffic through it. pion/ice.Agent was unable to handle IPv6 traffic with this design. It would appear that a local IPv4 candidate got a IPv6 request. pion/ice would discard the traffic. The TCPMux now creates a IPv4 and IPv6 candidate and everything works.

Don't drop Binding Requests in Controlled Agent

A controlled Agent would discard incoming Binding Requests if it didn't
cause the pair to be selected. For UDP Candidate this would be
interpreted as packet loss. For TCP Candidates not responding with a
Binding Success could be interpreted as a failure.

Firefox's ICE Agent would correctly disconnect TCP Candidates because of this
behavior.

The controlled Agent now correctly responds with a Binding Success message.


To test these behaviors I created https://github.com/Sean-Der/ice-tcp-test. It provides a Pion WebRTC server that supports IPv4/IPv6 ICE-TCP. You can then connect to it as an offerer or answer. If anyone is trying to reproduce issues this would be a good place to start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants