Added check to see if peer connection succeeded

This is related to the proxy-go deadlock bug #25688. If a client doesn't
do anything with the SDP answer, a token will get lost. Added a timeout
after a minute that checks the PeerConnection state and destroys the
peer connection and returns a token if did not yet succeed
This commit is contained in:
Cecylia Bocovich 2019-04-03 15:59:47 -04:00
parent c28c8ca489
commit 08f5205461

View file

@ -325,6 +325,20 @@ func makePeerConnectionFromOffer(sdp *webrtc.SessionDescription, config *webrtc.
pc.Destroy()
return nil, err
}
// Set a timeout on peerconnection. If the connection state has not
// advanced to PeerConnectionStateConnected in this time,
// destroy the peer connection and return the token.
go func() {
<-time.After(time.Minute)
if pc.ConnectionState() != webrtc.PeerConnectionStateConnected {
log.Println("Timed out waiting for client to open data cannel.")
pc.Destroy()
retToken()
}
}()
return pc, nil
}