CESNET / libnetconf2

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

possible TIMEOUT in libnetconf2 for yang-library retrieval in TLS #515

Open tivadaralex opened 1 month ago

tivadaralex commented 1 month ago

Hello,

We have an issue with TIMEOUT on TLS after we send message with get for yanglib after 0.4 seconds (on SSH there is no timeout after 0.4 seconds)

Sending message:<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1"><get xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><filter type="xpath" xmlns:yanglib="urn:ietf:params:xml:ns:yang:ietf-yang-library" select ="/yanglib:*"/></get></rpc> **nc WRN: Timeout for receiving reply to a <get> RPC expired.**

We tried to modify NC_READ_ACT_TIMEOUT at a higher value but we always have timeout after 0.4 seconds in TLS, in get_oper_data() function in session_client.c. nc_timeouttime_get() function modify it somehow. I think you can reproduce it by adding a time.sleep between get rpc and received rpc

We suspect that might be a timeout in pthread_mutex_clocklock()

We use 3.0.17 version for libnetconf2 and 2.2.8 version for libyang

Can you please check why we have this timeout always, even if we increase that flag (NC_READ_ACT_TIMEOUT).

michalvasko commented 1 month ago

I really do not know how to reproduce this and my guess is that there is something quite wrong on your end althought I am not sure what. What you can try, if you are using netopeer2-cli, to add parameter --rpc-timeout 5 to manually set the timeout for receiving the reply. But the default is definitely more than 400 ms.

tivadaralex commented 1 month ago

We are not using that netopeer2-cli. There is another way to increase the timeout? We tried to increase NC_READ_ACT_TIMEOUT, but in nc_timeouttime_get() function from session.c file some modifications are made for the timeout, can you please check also that?

michalvasko commented 1 month ago

All the CLI does is pass the timeout to nc_recv_reply(), you can customize it yourself in your code. If you changing NC_READ_ACT_TIMEOUT makes no difference than I cannot help you, the issue is totally unknown to me and you will have to debug it yourself. Unless you provide the exact steps documenting how to reliably reproduce it.

tivadaralex commented 1 month ago

Hello, I found why we had 0.4 seconds timeout, in nc_read_poll() function from io.c file - for TLS we have a hardcoded value for timeout which is 400 (0.4 seconds) given to poll method. ret = poll(&fds, 1, 400); i think you can now reproduce it. The server responds in like 0.8 seconds now Before in libnetconf2 the value was even smaller than this for TLS Why libnetconf2 doesn't support that yang library to be sent later on?

michalvasko commented 1 month ago

I have not found any fixed timeout of 400 ms for TLS, please point to the exact file and line.

tivadaralex commented 1 month ago

So in the latest version there is ret = nc_poll(&fds, 1, io_timeout); line 450 in io.c file, but we have something like: int pollTimeout = 400; ret = poll(&fds, 1, pollTimeout);

michalvasko commented 1 month ago

Do I understand it correctly, you have modified the code and set the timeout to 400 ms and now have a problem with it?