Skip to content

Query on api nc_client_monitoring_thread_start #616

Description

@srikanthsubbaramu

Hi Michal,

I have a query on the api nc_client_monitoring_thread_start,
We are trying to use this api to get callback on session disconnect, our server resides in a differnt system , we initially keep trying to connect to server, and we may not connect to netopeer2-server at initial attempts,

i went through documentation of the api, as per documentation we only need to call the api once, so any session established later would get monitored, but what i am seeing is certain times the monitoring thread is not started, so i added stop and start for connection attempt,

// Stop first in case it was running (ignore error if not running)
nc_client_monitoring_thread_stop();

int mret = nc_client_monitoring_thread_start(
    on_nc_session_disconnect, this, nullptr);
if (mret != 0) {
    LOG("WARNING: monitoring thread start failed");
} else {
    LOG("monitoring thread started on connect thread");
}

We try connecting to server in a loop until connection succeeds, but what i observed is thread stop happend in third attempt, ie first api never started monitoring thread,

Attempt1:
257:[ERR]: nc_client_monitoring_thread_stop: start
258-[ERR]: Client monitoring thread is not running.
259-[ERR]: nc_client_monitoring_thread_start: start
[2026-07-01 05:14:39.676690] [INFO] monitoring thread started on connect thread
Attempt2:
13405:[ERR]: nc_client_monitoring_thread_stop: start
13406-[ERR]: Client monitoring thread is not running.
13407-[ERR]: nc_client_monitoring_thread_start: start
[2026-07-01 05:14:40.230002] [INFO] monitoring thread started on connect thread

Attempt3:
13425:[ERR]: nc_client_monitoring_thread_stop: start
13426-[ERR]: Client monitoring thread exit.
13427:[ERR]: nc_client_monitoring_thread_stop: end
13428-[ERR]: nc_client_monitoring_thread_start: start

Although we have recieved successful return code for attempt1, the monitoring thread never started, i want to understand if there any other apis that i need to call before using this api.

Thanks,
Srikanth

Metadata

Metadata

Assignees

No one assigned

    Labels

    is:questionIssue is actually a question.status:completedFrom the developer perspective, the issue was solved (bug fixed, question answered,...)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions