Skip to content

Commit

Permalink
Fix stuck workflow when connection failed
Browse files Browse the repository at this point in the history
  • Loading branch information
mraerino committed Feb 4, 2024
1 parent 3e0c79a commit b68c942
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/webrtc/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import (
)

func RemoteChannel(ctx context.Context, localSession string, dst io.Writer) error {
ctx, cancel := context.WithCancel(ctx)
defer cancel()

peerConnection, err := webrtc.NewPeerConnection(config)
if err != nil {
return err
Expand All @@ -23,9 +26,10 @@ func RemoteChannel(ctx context.Context, localSession string, dst io.Writer) erro
iceGatheringDone := iceGather(peerConnection)
peerConnection.OnConnectionStateChange(func(s webrtc.PeerConnectionState) {
fmt.Printf("Peer Connection State has changed: %s\n", s.String())
if s == webrtc.PeerConnectionStateFailed {
cancel()
}
})
ctx, cancel := context.WithCancel(ctx)
defer cancel()
peerConnection.OnDataChannel(func(d *webrtc.DataChannel) {
fmt.Printf("New DataChannel %s %d\n", d.Label(), d.ID())

Expand Down

0 comments on commit b68c942

Please sign in to comment.