Add connection failure events for proxy timeouts

This change adds two new connection failure events for snowflake
proxies. One fires when the datachannel times out and another fires when
the connection to the proxy goes stale.
This commit is contained in:
Cecylia Bocovich 2022-02-14 14:00:01 -05:00
parent bcc162898a
commit 2c008d6589
No known key found for this signature in database
GPG key ID: 009DE379FD9B7B90

View file

@ -129,6 +129,8 @@ func (c *WebRTCPeer) checkForStaleness(timeout time.Duration) {
if time.Since(lastReceive) > timeout { if time.Since(lastReceive) > timeout {
log.Printf("WebRTC: No messages received for %v -- closing stale connection.", log.Printf("WebRTC: No messages received for %v -- closing stale connection.",
timeout) timeout)
err := errors.New("no messages received, closing stale connection")
c.eventsLogger.OnNewSnowflakeEvent(event.EventOnSnowflakeConnectionFailed{Error: err})
c.Close() c.Close()
return return
} }
@ -174,7 +176,9 @@ func (c *WebRTCPeer) connect(config *webrtc.Configuration, broker *BrokerChannel
case <-c.open: case <-c.open:
case <-time.After(DataChannelTimeout): case <-time.After(DataChannelTimeout):
c.transport.Close() c.transport.Close()
return errors.New("timeout waiting for DataChannel.OnOpen") err = errors.New("timeout waiting for DataChannel.OnOpen")
c.eventsLogger.OnNewSnowflakeEvent(event.EventOnSnowflakeConnectionFailed{Error: err})
return err
} }
go c.checkForStaleness(SnowflakeTimeout) go c.checkForStaleness(SnowflakeTimeout)