Skip to content

Avoid ssh_socket_exception_callback: Socket exception callback: 1 (0) warnings from libssh#591

Merged
michalvasko merged 7 commits intodevelfrom
ssh-socket-exception-fix
Apr 9, 2026
Merged

Avoid ssh_socket_exception_callback: Socket exception callback: 1 (0) warnings from libssh#591
michalvasko merged 7 commits intodevelfrom
ssh-socket-exception-fix

Conversation

@Roytak
Copy link
Copy Markdown
Collaborator

@Roytak Roytak commented Apr 7, 2026

Wait until EOF is received from the peer or timeout of 100ms elapses while waiting until the underlying SSH channel is closed. libssh should then update its internal state correctly and not print any warnings about normal disconnects.

Fixes #589

Wait until we receiver SSH EOF from the peer,
which avoids needlessly printing socket exception callbacks from libssh.
100ms should be more than enough to receive this message, if not
just free as before. Also possibly fix some race conditions
by locking io_lock before sending the EOF.

Fixes #589
@madis0911
Copy link
Copy Markdown

madis0911 commented Apr 8, 2026

I understand based on the comments from #589, this fix is done in libnetconf library.
as issue 589 is still open, should I wait for the closure of this issue to get libnetconf version where fix is available?

@Roytak
Copy link
Copy Markdown
Collaborator Author

Roytak commented Apr 8, 2026

I understand based on the comments from #589, this fix is done in libnetconf library. as issue 589 is still open, should I wait for the closure of this issue to get libnetconf version where fix is available?

Yes, you should wait, but honestly it's just the warning logs and it doesn't break anything. But we found out that it is not that simple to remove the warning logs, so it might take a bit longer to finish.

@Roytak Roytak force-pushed the ssh-socket-exception-fix branch from 507eb36 to 718d608 Compare April 8, 2026 13:21
@Roytak Roytak requested a review from Copilot April 8, 2026 13:22
Roytak added 5 commits April 8, 2026 15:26
If we receiver SSH_EOF in nc_write, it means that the peer won't be
sending anything anymore, but it can still receive, so we shouldn't
fail. This doesn't apply to nc_read, where it's still valid to fail.
Perform SSH connection aliveness check just like with other transports and
don't rely on libssh internal state tracking.
When a client DCs, send <close-session> + SSH EOF before waiting for
<ok> reply. When server goes to free its session it polls for the
SSH_EOF and this avoids socket exception warnings from libssh.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates libnetconf2 session teardown to perform a more graceful SSH/TLS shutdown (including waiting briefly for SSH channel EOF) so that libssh does not emit warnings during normal disconnect cleanup (fixing #589).

Changes:

  • Refactors client session free path to send <close-session>, signal transport shutdown (SSH EOF / TLS close_notify), and optionally wait for the close-session reply.
  • Adjusts SSH transport cleanup to poll briefly for peer EOF before freeing the SSH channel.
  • Improves/clarifies some SSH server-side disconnect error messages and bumps project version.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/session.c Introduces new close-session + transport-shutdown sequencing and SSH EOF polling during teardown.
src/io.c Changes SSH “connected” detection to be fd/poll-based and tweaks SSH write checks; adds RPC context validation in nc_write_msg_io().
src/session_client.c Extracts client message-queue and notification-thread teardown helpers; fixes pthread error reporting; switches RPC send to nc_write_msg_io().
src/session_server_ssh.c Uses ssh_is_connected() for server-side SSH loops and improves related error messages.
src/session_p.h Adds teardown helper prototypes and a new SSH EOF poll timeout constant.
CMakeLists.txt Increments micro version and SOVERSION micro.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Roytak Roytak force-pushed the ssh-socket-exception-fix branch from 718d608 to c3c443b Compare April 8, 2026 13:44
@michalvasko michalvasko merged commit 0e01d70 into devel Apr 9, 2026
11 checks passed
@michalvasko michalvasko deleted the ssh-socket-exception-fix branch April 9, 2026 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants