Skip to content

Reuse the daemon RPC connection for the whole request - #651

Open
jfpardy wants to merge 2 commits into
Icinga:mainfrom
jfpardy:fix/rpc-connection-per-request
Open

Reuse the daemon RPC connection for the whole request#651
jfpardy wants to merge 2 commits into
Icinga:mainfrom
jfpardy:fix/rpc-connection-per-request

Conversation

@jfpardy

@jfpardy jfpardy commented Aug 26, 2026

Copy link
Copy Markdown

Since #644 the sync RPC helper closes the daemon
client after every call. So the second syncRpcCall() of a request, and every
one after it, dies with Cannot write to JSON-RPC socket.

Problem

close() nulls $connection but leaves $pendingConnection holding a promise
for it, because connect() repopulates it right after $connected clears it.
The next connection() hands back that promise, resolves a connection that's
already closed, and rejects at JsonRpcConnection::sendRequest()'s writability
guard.

The daemon status page shows this behaviour. VMware API Connections renders fine,
then Pending HTTP Requests stops working and log level control stops displaying(#647).

Clearing $pendingConnection fixes the rejection, but then every call still
opens its own connection. I tried that first, and on my test deployment the daemon
would only answer a single status page load per restart. Going back to one
connection per request skips the reconnect entirely. The stream watcher from
#644 only has to be gone before the loop could next run, and await() has
already stopped the loop by then, so React's shutdown handler leaves it alone.

Changes

  • Share the RemoteClient across all RPC calls of a request and close it in a
    shutdown function, instead of a finally after every call.
  • Reset $pendingConnection in RemoteClient::close() too, outside the if,
    since a failed connect leaves $connection null while the rejected promise
    sticks around.

closes #647

@cla-bot

cla-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

Thank you for your pull request. Before we can look at it, you'll need to sign a Contributor License Agreement (CLA).

Please follow instructions at https://icinga.com/company/contributor-agreement to sign the CLA.

After that, please reply here with a comment and we'll verify.

Contributors that have not signed yet: @jfpardy

Details
  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Please contact us if you think this is the case.

  • If you signed the CLA as a corporation, your GitHub username may not have been submitted to us. Please reach out to the responsible person in your organization.

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.

Cannot write to JSON-RPC socket

1 participant