I have a request which processes thousands of data. So sometimes It takes more then 5 minutes to complete.
But unfortunately loopback returns timeout(no response from server) before process is completed.
In nodejs request. You can remove request timeout for specific request by below code.
request.setTimeout(0)
Can anyone tell me how can i do this for loopback remote method?
It was quite easy then it looked like.
All i had to do is pass http req object
in my remote method and then set timeout to 0.
Visit.remoteMethod(
'caculateDistance',
{
description: 'Calculate distance from beacon using rssi',
accepts: [
{ arg: "req", type: "object", http: { source: "req" } },
{ arg: 'activationId', type: 'string', required: true }
returns: { arg: 'data', type: 'Object', root: true },
http: { verb: 'patch', path: '/:activationId/calculate-distance' },
}
);
Visit.caculateDistance = function (httpReq, activationId, callbackFn) {
httpReq.setTimeout(0);
/////calculations....
});
Thanks anyway!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With