Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
xdeng opened this issue Aug 29, 2024 · 4 comments
Closed

Comments

@xdeng
Copy link

xdeng commented Aug 29, 2024

Your environment.

  • Version: v4.0.0-beta.29
  • Browser:
  • Other Information - stacktraces, related issues, suggestions how to fix, links for us to have context

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
Copy link
Author

xdeng commented Aug 29, 2024

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

@xdeng
Copy link
Author

xdeng commented Aug 29, 2024

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 }

@Sean-Der
Copy link
Member

Sean-Der commented Oct 7, 2024

@xdeng The Detached DataChannel API isn't popular with many users like this issue.

The behavior described here is by design. A PeerConnection that has failed can go back to Connecting/Connected! If the user does a ICE Restart.

When the PeerConnection goes to Closed (DTLS Close or PeerConnection.Close() only does that mean that connection is terminally closed.

Sorry about the API frustrations. I am not sure of a better way to do this yet :/

@Sean-Der Sean-Der closed this as not planned Won't fix, can't repro, duplicate, stale Oct 7, 2024
@xdeng
Copy link
Author

xdeng commented Oct 8, 2024

@Sean-Der Thanks for your answer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants