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

Wrong remote candidate is selected #305

Open
jech opened this issue Nov 28, 2020 · 7 comments
Open

Wrong remote candidate is selected #305

jech opened this issue Nov 28, 2020 · 7 comments
Labels
bug Something isn't working

Comments

@jech
Copy link
Contributor

jech commented Nov 28, 2020

Unnamed SFU using Pion running on remote host. Client is Chromium on Linux and is multihomed: has both an Ethernet and a Wifi connection. The client offers four host candidates, IPv4+IPv6 for each of the two interfaces.

When Chomium is the controlling agent, then the Ethernet interface is chosen. When Pion is the controlling agent, on the other hand, the WiFI interface is chosen deterministically.

A few other elements:

It is my understanding that Pion does not use the network cost, but that the candidate priority should be enough to do the right thing. This may be related to #82.

@jech
Copy link
Contributor Author

jech commented Nov 28, 2020

I can confirm that the priorities of Chromium's host candidates are reasonable:

  • 2122262783 for the IPv6 address of the Ethernet interface;
  • 2122194687 for the IPv4 address of the Ethernet interface;
  • 2122131711 for the IPv6 address of the WiFi interface; and
  • 2122063615 for the IPv4 address of the WiFi interface.

So it definitely looks like there's something wrong with Pion's candidate selection.

@jech
Copy link
Contributor Author

jech commented Dec 5, 2020

I am no longer able to reproduce this — it looks like Pion is choosing the candidate with the highest priority, as it should. Closing for now.

@jech jech closed this as completed Dec 5, 2020
@jech
Copy link
Contributor Author

jech commented Dec 6, 2020

The issue cannot be reproduced locally, but it is definitely there when the server is remote.

Interestingly enough, if I trigger an ICE restart after the connection is established, then Pion switches to the right candidate. So this might very well be a timing issue: the WiFi candidate is chosen before the Ethernet candidate is received. Perhaps delaying ICE by a fraction of a second would help?

@jech jech reopened this Dec 6, 2020
@jech
Copy link
Contributor Author

jech commented Dec 9, 2020

After investigation, it looks like Pion's ICE code does the right thing wrt. priorities — the code that selects the highest priority candidate pair looks correct to my untrained eyes.

@Sean-Der has suggested that the wrong selection might be due to defaultHostAcceptanceMinWait in agent_config.go being 0.

@jech
Copy link
Contributor Author

jech commented Dec 12, 2020

After adding

		s.SetHostAcceptanceMinWait(2000 * time.Millisecond)
		s.SetSrflxAcceptanceMinWait(2000 * time.Millisecond)
		s.SetSrflxAcceptanceMinWait(2000 * time.Millisecond)
		s.SetPrflxAcceptanceMinWait(2000 * time.Millisecond)

Pion still chooses the wrong candidate. Still trying to understand the issue.

@aziztitu
Copy link

@jech Were you able to find a solution for this? I'm facing a similar problem at the moment. Pion seems to choose a Relay candidate with higher priority while a srflx candidate with lower priority is available

@jech
Copy link
Contributor Author

jech commented Mar 19, 2022

No, I never did. I tried tweaking all sorts of constants in the code, and I still got randomly wrong choices.

@stv0g stv0g added the bug Something isn't working label Apr 12, 2023
@stv0g stv0g changed the title Pion chooses wrong remote candidate Wrong remote candidate is selected Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants