Temporal Client connection becomes unresponsive


We have an API that exposes signals/queries towards runnning workflows. This is implemented by using the ‘@temporalio/client’ library.

In the first iteration, we set up a connection to the temporal server on the start of the API server and reused this connection for every request. This lead to the API becoming unresponsive after some time. I assume that the reason is that one connection isn’t meant to last this long (days or weeks in our case, depending on how often we deploy our API).

I’m currently in the process of implementing a connection pool for the temporal connections, but that brings with it a lot of complexity and I’d rather have a simple solution. The simplest solution I can think of is to create a new connection for every request and close the connection after every request, but that bloats the code and makes every request slower.

What is the recommended way to deal with this?


A single connection is meant to be reused for the lifetime of your application.
Which SDK version are you using?


thanks for your reply. Currently using version 1.4.4, but only upgraded recently after ditching the one long-lived connection.

Were there issues with the connection before? Previous version was 1.0.1.

If there were changes between these versions I can go back and try the single connection again but now with version 1.4.4.

In 1.4.2 we added grpc keepalive to the default connection options.
It might explain what you were seeing in case your app was idle for a while.