pion / webrtc

Pure Go implementation of the WebRTC API
https://pion.ly
MIT License
13.41k stars 1.63k forks source link

The connection status has failed,Why is the read function still blocking? #2891

Open xdeng opened 2 weeks ago

xdeng commented 2 weeks ago

Your environment.

What did you do?

data-channels-detach

What did you expect?

What happened?

The connection status is

OnConnectionStateChange: disconnected OnConnectionStateChange: failed

dataChannel.Detach() ---> ReadWriteCloser, Why doesn't it fail when reading, but keeps blocking?

Need to call peerConnection.Close(), The read function will fail to exit.

xdeng commented 2 weeks ago

I would also like to ask how to implement timeout for the separated read-write close functions? Or context

xdeng commented 2 weeks ago

raw, _:= dataChannel.Detach()

OnConnectionStateChange: disconnected ❌ for{ raw.Read()...//blocking } OnConnectionStateChange: failed ❌ for{ raw.Read()...//blocking }

Active call dataChannel.Close() ❌ for{ raw.Read()...//blocking } Active call raw.Close() ❌ for{ raw.Read()...//blocking } Active call peerConnection.Close() ✔ for{ raw.Read()...//Will fail and exit, will not block }