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

WebRTC DataChannel shuts down(close) after some time of operation #1070

Open
Ricarnev opened this issue Feb 15, 2024 · 2 comments
Open

WebRTC DataChannel shuts down(close) after some time of operation #1070

Ricarnev opened this issue Feb 15, 2024 · 2 comments
Labels

Comments

@Ricarnev
Copy link

Greetings, everyone. I am using DataChannel to transmit frames. After an indefinite amount of time (always different times, but within 10 minutes), my DataChannel with whoever is broadcasting is interrupted. When this happens, an onclose event is called on the JavaScript client side, which tells me that the DataChannel is closed. This event is not called in SipSorcery. I tested using a direct connection of 2 clients directly and my DataChannel worked stably.So I have suspicions that the error occurs on the SipSorcery side.
What I am using:
-Sending packets by the client to the server only when the send buffer is empty
-Packets are no more than 16kb in size (I have since replaced this with a value for the maximum size passed to sctp).
-Send a new packet only after a message that the server has received the previous packet.
Here is the log of the moment when my DataChannel goes down:

[19:04:19 DBG] SCTP association data send thread started for association 5000:5000:65484.
[19:12:44 WRN] DTLS client raised unexpected alert: fatal(2), bad_record_mac(20).
[19:12:44 ERR] SCTP fatal error processing RTCSctpTransport receive. Org.BouncyCastle.Crypto.Tls.TlsFatalAlert: bad_record_mac(20)
 ---> Org.BouncyCastle.Crypto.InvalidCipherTextException: mac check in GCM failed
   at Org.BouncyCastle.Crypto.Modes.GcmBlockCipher.DoFinal(Byte[] output, Int32 outOff) in /_/crypto/src/crypto/modes/GCMBlockCipher.cs:line 488
   at Org.BouncyCastle.Crypto.Tls.TlsAeadCipher.DecodeCiphertext(Int64 seqNo, Byte type, Byte[] ciphertext, Int32 offset, Int32 len) in /_/crypto/src/crypto/tls/TlsAeadCipher.cs:line 219
   --- End of inner exception stack trace ---
   at Org.BouncyCastle.Crypto.Tls.DtlsTransport.Receive(Byte[] buf, Int32 off, Int32 len, Int32 waitMillis) in /_/crypto/src/crypto/tls/DtlsTransport.cs:line 47
   at SIPSorcery.Net.RTCSctpTransport.DoReceive(Object state)
[19:12:44 WRN] SCTP association 5000:5000:65484 receive thread stopped.
[19:12:44 WRN] WebRTC data channel send failed due to SCTP transport in state Closed.

Dear users, developers, could you please tell me what the problem is? Or maybe it is a library bug and it will help you to fix bugs

@ChristopheI
Copy link
Collaborator

ChristopheI commented Feb 19, 2024

Could you describe a little more what is your topology ? You talked about a JS client , a server and Sipsorcery ...
You have 2 clients (Web + SipSorcery) and in the middle a server ?

Do you send paquets often ? i.e. is there sometimes a long period without sending any data ?

The delay of 10 mns let me think about a device (a switch for example) which cut the link after some period of inactivity.

Have you tested a echo scenario (small packets but "often" like every seconds) ? Is it cut before 10 mns ?

@Ricarnev
Copy link
Author

Ricarnev commented Feb 22, 2024

I have an ASP .Net Core server that uses SignalR for signaling and Sipsorcery to handle WebRTC. The client role is played by a React application. There is no middleware between them, they communicate directly. Packets are sent according to how they are decoded (if the image on the screen changes, a frame packet is sent. If not, no packets are sent). This is the logic of the Javascript decoder. I think in about 10 minutes the app breaks when transferring large packages and often (0-16kb every second). If you transfer small packages and not so often - the application will work longer. The server and client work on the same device, i.e. both on localhost. At the same time, I do nothing. The connection is fully established and I just leave the screen streaming (I open any YouTube video, so you get more packages and more often).

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

No branches or pull requests

2 participants