Break from infinite client-broker poll after call to snowflakes.End()
This bug was originally brought to my attention in #40018 (comment 2715140) but it's a more general issue than just for snowflake on mobile devices.
The following for loop in client/lib/webrtc.go will poll infinitely until it receives an available snowflake:
// exchangeSDP sends the local SDP offer to the Broker, awaits the SDP answer,
// and returns the answer.
func exchangeSDP(broker *BrokerChannel, offer *webrtc.SessionDescription) *webrtc.SessionDescription {
// Keep trying the same offer until a valid answer arrives.
for {
// Send offer to broker (blocks).
answer, err := broker.Negotiate(offer)
if err == nil {
return answer
}
log.Printf("BrokerChannel Error: %s", err)
log.Printf("Failed to retrieve answer. Retrying in %v", ReconnectTimeout)
<-time.After(ReconnectTimeout)
}
}
Because of ongoing work on matching up clients with compatible proxies in #40013 (closed), we currently have almost no "unrestricted" proxies available, meaning snowflake clients behind restricted NATs have to poll for a very long time before getting a snowflake. Normally the potentially infinite polling isn't a problem as long as there are snowflakes available, but if the client makes a call to snowflakes.End()
we should stop polling regardless of whether or not snowflakes are available.