Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Regression in KMS 7 - data channel open indication does not come

125 views
Skip to first unread message

Neil Young

unread,
Jun 6, 2023, 2:12:12 PM6/6/23
to kurento
Since years with KMS6 I'm noticing a problem with my send data channel.

The data channel is opened, either from the browser or from an Android app using the Google WebRTC stack (libwebrtc).

In the past I got a callback from the stacks below, when the data channel has been opened. I'm not getting this callbacks with KMS 7, just the close callback comes.

In browser:

if (this.sendData) {
this.sendChannel = this.pc.createDataChannel('sendDataChannel')
this.sendChannel.binaryType = 'arraybuffer'
this.sendChannel.addEventListener('open', this.onPCSendChannelStateChange)
this.sendChannel.addEventListener('close', this.onPCSendChannelStateChange)
this.sendChannel.addEventListener('error', error => {
if (error.error.errorDetail == "sctp-failure" && error.error.sctpCauseCode == null) {
// Just the reaction on the internal close
}
else {
console.error('Error in sendChannel:', error)
}
})
}
...
// Send data channel status callback, just notifies the using app
onPCSendChannelStateChange = () => {
const readyState = this.sendChannel.readyState
if (readyState === 'open') {
this.notificationCallback({ event: this.constants.event_send_datachannel_opened })
}
else {
if (readyState === 'closed') {
this.notificationCallback({ event: this.constants.event_send_datachannel_closed })
}
}
}

Neil Young

unread,
Jun 6, 2023, 2:42:14 PM6/6/23
to kurento
The prove:

KMS 6.18 traces this (and it works):

```
2023-06-06T18:36:53,312407 2520 0x00007f913ffe7700 warning kmswebrtcsession          kmswebrtcsession.c:1177 kms_webrtc_session_data_channel_opened_cb() <kmswebrtcsession564>  No more than 1 data channel are allowed
```

KMS7 traces this (and it does not work):

```
2023-06-06T18:26:33,415748 775 0x00007f32daffd700 warning kmswebrtcdatachannelbin   kmswebrtcdatachannelbin.c:718 kms_webrtc_data_channel_bin_handle_open_request() <kmswebrtcdatachannelbin210>  Invalid priority level negotiated: 192
```

Neil Young

unread,
Jun 6, 2023, 2:49:15 PM6/6/23
to kurento
Wondering that "priority" is validated. It is an experimental feature, not supported by any browser AFAIK

Neil Young

unread,
Jun 6, 2023, 4:56:59 PM6/6/23
to kurento
Argh... wanted to do a source compilation, failed with several things

-- CMake project: kurento-jsonrpc

-- Found KurentoUtils: 7.0.1~36.g32ff07d0d (found version "7.0.1~36.g32ff07d0d") 

-- [FindKurentoUtils.cmake] Found: /home/ubuntu/kurento/server/build-RelWithDebInfo/cmake-utils

-- Version info from git: 7.0.1~36.g32ff07d0d

-- Project version: kurento-jsonrpc-7.0.1~36.g32ff07d0d

-- Checking for module 'jsoncpp>=1.7.2'

--   Found jsoncpp, version 1.7.4

-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0") found components: unit_test_framework 

-- Adding test: test_rpc

-- Adding test: test_serialize

-- CMake project: kurento-module-core

-- [FindKurentoUtils.cmake] Found: /home/ubuntu/kurento/server/build-RelWithDebInfo/cmake-utils

-- [FindKurentoModuleCreator.cmake] Found: /home/ubuntu/kurento/server/build-RelWithDebInfo/module-creator/kurento-module-creator

-- Resolving KurentoModuleCreator version ^7.0.0 with 7.0.1-SNAPSHOT

Run command: '/home/ubuntu/kurento/server/build-RelWithDebInfo/module-creator/kurento-module-creator -r;/home/ubuntu/kurento/server/module-core/src/server/interface;-dr;/usr/share/kurento/modules;-s;version'

CMake Error at module-core/cmake/Kurento/CodeGenerator.cmake:80 (message):

  Code generator failed!


  **Command stdout**: Not system kurento-module-creator, running from

  /home/ubuntu/kurento/server/build-RelWithDebInfo/module-creator


  


  **Command stderr**: Exception in thread "main"

  org.kurento.modulecreator.KurentoModuleCreatorException: Import 'core' with

  version ^6.0.0 not found in dependencies, found version: 7.0.1-dev


  at

  org.kurento.modulecreator.definition.ModuleDefinition.resolveImports(ModuleDefinition.java:390)



  at

  org.kurento.modulecreator.definition.ModuleDefinition.resolveModule(ModuleDefinition.java:301)



  at

  org.kurento.modulecreator.ModuleManager.resolveModules(ModuleManager.java:38)



  at

  org.kurento.modulecreator.KurentoModuleCreator.loadModulesFromKmdFiles(KurentoModuleCreator.java:313)



  at

  org.kurento.modulecreator.KurentoModuleCreator.printValues(KurentoModuleCreator.java:367)



  at org.kurento.modulecreator.Main.showValues(Main.java:129)


  at org.kurento.modulecreator.Main.main(Main.java:105)


Call Stack (most recent call first):

  module-core/cmake/Kurento/CodeGenerator.cmake:1069 (execute_code_generator)

  module-core/CMakeLists.txt:41 (get_values_from_model)



-- Configuring incomplete, errors occurred!

See also "/home/ubuntu/kurento/server/build-RelWithDebInfo/CMakeFiles/CMakeOutput.log".

See also "/home/ubuntu/kurento/server/build-RelWithDebInfo/CMakeFiles/CMakeError.log".

[build-run.sh] ERROR (1)

ubuntu@kms7:~/kurento/server$ 



Sucks. Time to say good bye to KMS

Neil Young

unread,
Jun 7, 2023, 7:39:39 AM6/7/23
to kurento
Here is what I found out so far (I'm referring to a source installation of KMS7, but the problem was observed with an APT installation first):

After my Node JS app creates the data. channel I'm seeing this trace in KMS log:

  GST_DEBUG ("Creating data channel with stream id %d", stream_id);

It is issued in line 1033 of server/module-elements/src/server/implementation/objects/WebRtcEndpointImpl.cpp

The emitted "create-data-channel" message lands in server/module-elements/src/gst-plugins/webrtcendpoint/kmswebrtcendpoint.c line 634.
From there it goes to line 713 in server/module-elements/src/gst-plugins/webrtcendpoint/kmswebrtcdatasessionbin.c.

There an attempt to create the data channel is made by calling kms_webrtc_data_session_bin_create_data_channel. After return it is checked,
if the session is established. This is not the case, so the processing is postponed by putting the channel into a list g_slist.

The final "connected" state for the session is supposed to be set in kms_webrtc_data_session_bin_association_established in the same file, but this function (as a reaction
to the GStreamer signal "sctp-association-established") is never called. Hence the data channel is never reported as "open" to the upper layers.

So nobody sets the session state to connected and nobody walks the "pending actions" list.

Petr Kazda

unread,
Sep 12, 2023, 4:50:15 AM9/12/23
to kurento
Yep, we are having the same issue - the data channels are not pushing data through, seem that the reason you found is the culprit.

Did you managed to solve the problem somehow?

Neil Young

unread,
Sep 12, 2023, 9:55:41 AM9/12/23
to kurento
Yes, it is solved, at least for me. I'm compiling KMS7 from source via Ansible. And this is the patch for a particular file, which made the send channel run:

diff --git a/server/module-core/src/gst-plugins/commons/sdpagent/kmssdpsctpmediahandler.c b/server/module-core/src/gst-plugins/commons/sdpagent/kmssdpsctpmediahandler.c
index 0dae0663c..2ccffbd44 100644
--- a/server/module-core/src/gst-plugins/commons/sdpagent/kmssdpsctpmediahandler.c
+++ b/server/module-core/src/gst-plugins/commons/sdpagent/kmssdpsctpmediahandler.c
@@ -362,8 +362,8 @@ kms_sdp_sctp_media_handler_add_offer_attributes (KmsSdpMediaHandler * handler,
// `SCTP_CANT_STR_ASSOC` errors. With random ports, the error still happens
// but seems to be much less frequent.
- //guint16 sctp_port = 5000;
- guint16 sctp_port = (guint16)g_random_int_range (1024, G_MAXUINT16);
+ guint16 sctp_port = 5000;
+ //guint16 sctp_port = (guint16)g_random_int_range (1024, G_MAXUINT16);
gchar *sctp_port_str = g_strdup_printf ("%u", sctp_port);


I had a lengthy session with Juan from Kurento regarding this. In the end this was his suggestion and it worked.


<quote>

Also, we did find the SCTP_CANT_STR_ASSOC upon updating Kurento to Ubuntu 20.04, and there is an open issue report for it: sctplab/usrsctp#314

The cause of the issues are still not very clear, and I'm afraid that I had to progress with making everything else work, so this was left in a bit of hold. But, for testing with Wireshark, it is probably very helpful to disable the random port selection in Kurento, and instead use the fixed port 5000, which was used before with Kurento 6. To do that, swap the comments of these two lines:

https://github.com/Kurento/kurento/blob/7.0.0/server/module-core/src/gst-plugins/commons/sdpagent/kmssdpsctpmediahandler.c#L365-L366

from

//guint16 sctp_port = 5000;
guint16 sctp_port = (guint16)g_random_int_range (1024, G_MAXUINT16);

to

guint16 sctp_port = 5000;
//guint16 sctp_port = (guint16)g_random_int_range (1024, G_MAXUINT16);

And then Kurento should always use 5000 as its SCTP port in SDP Offers. This should make it easier to inspect traffic with Wireshark.

</quote>

I have that all in an Ansible script, compilation, patch, installation, so if more details are required, let me know. I recall the tricky part was to assemble all the modules after compilation and install it correctly in the target system.

Note: I'm moving away from Kurento in favour of MediaSoup, so I'm not fully up to date. I recall I reported this as fix, so I wonder, if this hasn't found the way into a later release of KMS 7...

Petr Kazda

unread,
Oct 10, 2023, 4:23:20 AM10/10/23
to kurento
Well, I took the hard path and built it from sources. Once again I was absolutely stunned how unfinished this piece of s...oftware is. It is absolutely ridiculous that this is so widely spread and how many companies are relying on it.
The datachannels were not implemented at all in AlphaBlending Hub (basically the only hub with datachannels support is Composite), no surprise it was not working. There are errors everywhere, even in the buildscripts.

If will stumble here - take my advice, look for some other media server!!!

Kurento is practically unsupported, it has bugs which are not being addressed for years and you will probably end tearing your hair, because you made wrong decision by going with Kurento which is hard to replace for me now.
Reply all
Reply to author
Forward
0 new messages