webrtc icon indicating copy to clipboard operation
webrtc copied to clipboard

Data channel does not close if dataChannel.Close is called in the OnDataChannel handler

Open timmattison opened this issue 1 year ago • 1 comments

Your environment.

  • Version: 3.2.24
  • Browser: N/A

What did you do?

I set up a handler for OnDataConnection on the PeerConnection struct. This handler checks a few things to see if it's interested in the data channel or not. If it decides that it isn't interested it calls dataChannel.Close(). Otherwise, it sets up the OnOpen and OnMessage handlers.

What did you expect?

I expected the data channel to close on both sides of the connection immediately.

What happened?

The data channel's state went from connecting to open and stayed open. The call to dataChannel.Close() returns a nil error.

If I put the logic in the OnOpen handler it works. But I would've expected an error from Close() or for it to work no matter when it is called.

timmattison avatar Feb 02 '24 20:02 timmattison

@timmattison would you mind sharing some code?

stephanrotolante avatar Apr 22 '24 05:04 stephanrotolante