File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -301,6 +301,16 @@ func (co *PeerConnection) Start() error {
301
301
close (co .failed )
302
302
303
303
case webrtc .PeerConnectionStateClosed :
304
+ // "closed" can arrive before "failed" and without
305
+ // the Close() method being called at all.
306
+ // It happens when the other peer sends a termination
307
+ // message like a DTLS CloseNotify.
308
+ select {
309
+ case <- co .failed :
310
+ default :
311
+ close (co .failed )
312
+ }
313
+
304
314
close (co .done )
305
315
}
306
316
})
Original file line number Diff line number Diff line change 372
372
return ;
373
373
}
374
374
375
- if ( this . pc . connectionState === 'failed' ) {
375
+ // "closed" can arrive before "failed" and without
376
+ // the close() method being called at all.
377
+ // It happens when the other peer sends a termination
378
+ // message like a DTLS CloseNotify.
379
+ if ( this . pc . connectionState === 'failed'
380
+ || this . pc . connectionState === 'closed'
381
+ ) {
376
382
this . handleError ( 'peer connection closed' ) ;
377
383
} else if ( this . pc . connectionState === 'connected' ) {
378
384
if ( this . conf . onConnected !== undefined ) {
Original file line number Diff line number Diff line change 468
468
return ;
469
469
}
470
470
471
- if ( this . pc . connectionState === 'failed' ) {
471
+ // "closed" can arrive before "failed" and without
472
+ // the close() method being called at all.
473
+ // It happens when the other peer sends a termination
474
+ // message like a DTLS CloseNotify.
475
+ if ( this . pc . connectionState === 'failed'
476
+ || this . pc . connectionState === 'closed'
477
+ ) {
472
478
this . handleError ( 'peer connection closed' ) ;
473
479
}
474
480
} ;
You can’t perform that action at this time.
0 commit comments