CESNET / libnetconf2

C NETCONF library
BSD 3-Clause "New" or "Revised" License
203 stars 147 forks source link

Netconf connection times out even with idle-timeout configured to 0 #496

Closed Krisscut closed 2 months ago

Krisscut commented 4 months ago

Hi !

Versions: netopeer2-2.2.13 sysrepo-2.2.150 libnetconf2-3.0.11.devel libyang-2.1.148 libssh-0.10.5

I'm having an issue using the idle-timeout to configure a listen endpoint like so: https://github.com/CESNET/libnetconf2/blob/47ca0fb5f94588d112ec2bf26946948189e1c18d/modules/ietf-netconf-server%402023-12-28.yang#L452-L462

image

I noticed there was an issue created earlier this year about it, see https://github.com/CESNET/libnetconf2/issues/459 I have the fix in my version (see last one): image

I'm having this error log, note that I patched some more logs in the lib and the timeout is correctly set to -1 image

image

Could it be the version of the libssh that cause the problem ?

michalvasko commented 4 months ago

Seems to be a bug in libssh, this timeout is used, which is actually 0. I will report it later but it will take some time until it gets into an actual release.

Krisscut commented 4 months ago

Applying that change seems to solve the issue without any side effects that I noticed.

diff --no-dereference -ruN libssh-0.10.5.origin/src/session.c libssh-0.10.5/src/session.c
--- libssh-0.10.5.origin/src/session.c  2023-05-04 14:37:20.000000000 +0300
+++ libssh-0.10.5/src/session.c 2024-07-24 17:03:43.207785726 +0300
@@ -724,7 +724,7 @@
     int ret = SSH_OK;

     /* If a timeout has been provided, use it */
-    if (timeout >= 0) {
+    if (timeout >= 0 || timeout == SSH_TIMEOUT_INFINITE) {
         timeout_ms = timeout;
     } else {
         if (ssh_is_blocking(session)) {
Krisscut commented 4 months ago

For reference for future viewers, link to issue on libssh repo https://gitlab.com/libssh/libssh-mirror/-/issues/261

michalvasko commented 3 months ago

It will take some time till the fix is made and then released, so a workaround was committed until then.