SAP / node-rfc

Asynchronous, non-blocking SAP NW RFC SDK bindings for Node.js
Apache License 2.0
249 stars 73 forks source link

Question: Can we set a timeout for a Direct Client Call #218

Closed JosephJeffs closed 3 years ago

JosephJeffs commented 3 years ago

**Is your feature request related to a problem? Yes, I am making a function call to an SAP system that is taking a long time to respond. Once I have 4 requests outstanding, I can not open another client until SAP responds.

Describe the solution you'd like Is it possible, to abort an outstanding request or set a timeout value for how long to wait for a response.

Describe alternatives you've considered I have tried using the Client.close() function, but it does not free the connection

Additional context I am running the application in express.

Thank you for your help.

bsrdjan commented 3 years ago

The maximum runtime and inactivity timeouts of RFC connections are configured by basis profile parameters in a backend system (transactions RZ10, RZ11...). Would that be of any help ?

Similar request: #105

JosephJeffs commented 3 years ago

Thank you for the quick reply. its unlikely that this could be a solution as it would impact other processes that may need a longer run time than what would be acceptable for my application.

bsrdjan commented 3 years ago

The cancel() method is now exposed at add-on, client and pool level and can be used to terminate ongoing RFC calls.

Can you test it by checkout the feature/connection-cancel branch and build the add-on from source?

Documentation and example: feature/connection-cancel/doc/usage.md#cancel-connection

The timeout is not implemented but can be added the standard way at application level.

bsrdjan commented 3 years ago

The timeout and cancel event are added:

Feedback and suggestions welcome before released.

JosephJeffs commented 3 years ago

The documentation and examples look great. The functionality is just what I would want. I am not sure how quickly I will be able to try it out. Since I am running on Kubernetes, I also have the option to turn off the readiness probe and eventually kill it if the requests do not come back. In that design I would just need to keep track of how many connections I have open at a time and create a new route to respond when I am running out. Thank you again for your help.

bsrdjan commented 3 years ago

Released in 2.5.0