cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Close inactive clients in node rfc pool

jonash01
Explorer
0 Likes
721

Hello,

i have some problems with this codesnipped:

private rfcPools: Map<RfcConnectionParameters, Pool> = new Map();
let pool = new Pool({connectionParameters: connectionParams});
this.rfcPools.set(connectionParams, pool);
client = (await pool.acquire()) as Client

doesn't that await could run forever if there is no client availabe at that time?

I am looking for an idea how I can identify inactive clients or clients which are stuck in a task and how I can release those clients such that I can acquire new one.

I am looking forward for some ideas

Accepted Solutions (0)

Answers (1)

Answers (1)

Srdjan
Product and Topic Expert
Product and Topic Expert

Hello Jonas,

Pool.acquire() will check if already open Client connection is already available in Pool. If not it will try to open new connection and return it back. If new connection could not be opened, like server limit of max number of open RFC connections exceeded, the exception is thrown. When the network is down, it takes up to 60 seconds to throw an error. If you experience waiting "forever" we need to investigate.

The client can be considered "inactive" when waiting too long for the response from server. Such client connection can be released using "cancel" method: https://github.com/SAP/node-rfc/blob/main/doc/usage.md#cancel-connection

There is also a "timeout" option, which can be configured for the client and/or for particular RFC call:

- https://github.com/SAP/node-rfc/blob/main/doc/usage.md#client-options

- https://github.com/SAP/node-rfc/blob/main/doc/usage.md#rfc-call-options

It either case, when timeout exceeded, the connection is canceled / released.

Hope this helps in your usage scenario

Best regards,

Srdjan