Extensions timeout

Mirek Lauš mirek at laus.cz
Wed Jan 30 03:27:50 EST 2019


Hello Genieacs users,

my extensions sometimes results in timeout without a reason giving a NodeJS
error in the log:

>  1: node::Abort(void) [/usr/local/bin/node]
>  2: node::PlatformInit(void) [/usr/local/bin/node]
>  3: node::Start(int, char**) [/usr/local/bin/node]
>  4: _start [/usr/local/bin/node]

My extension is called from Provision script:

> let genieacsId = declare("DeviceID.ID", {value: 1}).value[0];
> let externalIp = declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress", {value: 1}).value[0];
> let connReqUrl = declare("InternetGatewayDevice.ManagementServer.ConnectionRequestURL", {value: 1}).value[0];
> 
> let args = {id: genieacsId, url: connReqUrl, ip: externalIp};
> 
> log('remoteCallback call script');
> 
> let resp = ext('remote', 'remoteCallback', JSON.stringify(args));
> log('remote response ' + genieacsId + ': ' + resp);

And the extension:

> const API_URL = 'https://remote.url/api/genieacs';
> const url = require("url");
> const http = require(API_URL.split(":", 1)[0]);
> 
> const logger = require('../../lib/logger');
> 
> function remoteCallback(args, callback) {
> 
>   let params = JSON.parse(args[0]);
> 
>   const uri = API_URL + "/callback.pl?id=" + params.id + "&url=" + params.url + "&ip=" + params.ip;
> 
>   let options = url.parse(uri);
>   options.headers = { accept: 'application/json', "content-type": 'application/json' };
> 
>   logger.info({message: 'post callback ' + params.id});
> 
>   let request = http.get(options, function (response) {
> 
>     if (response.statusCode == 404) {
>       return callback(null, null);
>     }
> 
>     if (response.statusCode >= 400) {
>       return callback(new Error("Unexpected error. Response Code: " +
>       response.statusCode + '. Status Message: ' + response.statusMessage + '. t: ' + typeof response.statusCode));
>     }
> 
>     let data = "";
> 
>     response.on("data", function(d) {
>       data = data + d.toString();
>     });
> 
>     response.on("end", function () {
>       logger.info({message: 'post callback response: ' + data});
>       return callback(null,data);
>     });
> 
>   });
> 
>   request.on("error", function (err) {
>     logger.info({message: 'post callback error: ' + err});
>     callback(err);
>   });
> 
> }
> 
> exports.remoteCallback = remoteCallback;


How to debug this?

Regards
Mirek


More information about the Users mailing list