Closed Berdmanfolk closed 2 years ago
A longer RFC call can be simulated by calling RFC_PING_AND_WAIT
ABAP function module. It will wait for a number of seconds, provided in input parameter SECONDS, and return.
The timeout can be tested by calling this function module with SECONDS: 5
for example and setting connection timeout to 3 seconds. After 3 second the timeout event will be fired, as shown in direct-callback.mjs source code example. Few more examples are provided in a parent folder
The client.cancel()
can be tested in a similar way. Call RFC_PING_AND_WAIT
and while waiting for the call to complete, call the cancel()
method, exposed at addon, pool or client level. Examples can be found in unit tests, like client.cancel.spec.js
Hope this helps further.
I think, I understand - we are talking about when the connection to the sap system has already taken place. And if it is possible to interrupt the connection when the connection to the stand-alone system has not yet been completed, but due to some network problems it takes a long time?
In case of network problems the default timeout is 1 min, defined by SAP NWRFC SDK. After that time the network error is raised with more diagnostic info.
The application can define its own shorter timeout and in that case no info on network error is received, something like:
const RFC = require("node-rfc");
const client = new RFC.Client({ dest: "MME" });
(async () => {
try {
// check of opening connection takes longer than 1 sec
setTimeout(() => {
if (!client.connectionHandle) {
// handle open timeout here
}
}, 1000);
await client.open();
console.log("Connection opened");
} catch (ex) {
console.log("error", ex, client.alive, client.connectionHandle);
}
})();
Please re-open if needed.
Oh, It is need
Only opened connection can be cancelled. The cancel() method requires connection handle and the handle is known only after connection opened. How would you like to use cancellation, can you describe the usage scenario?
Hello @bsrdjan! Can you please to clarify how to use Client cancellation. I was compile for last version 2.5.1. but now when I try to call method Cancel() I gett error that method is not found. In devetools of browser I don see this method:
I was try also to get timeout by event is using such code: But timeout is not arise.
Can you pleaswe clarify what I do wrong?