Dear all,
I have Provision code (see below) , this code is launched every inform (for the tests)
When the script is lunched, it’s work fine (update V.params) , but it doesn’t end properly .
I get The TR-069 session was unsuccessfully terminated on other channels
If in Provison code I remove the ext script calling, it’s OK, the end of the script is done correctly, and the other chanels are executed correctly
Provision code
const now = Date.now();
log('Start provision script');
let provisioned = declare("Tags.Basic_Provisioned", {value: 1});
if (provisioned.value !== undefined) {
log('CPE is (allegedly) provisioned, returning');
return;
}
let ip = declare("VirtualParameters.ip", {value: 1}).value[0];
let mac = declare("VirtualParameters.WanMac", {value: 1}).value[0];
let args = {ip: ip, mac: mac};
log('Args ' + JSON.stringify(args));
//Get the params from api
log('Launch ext script');
let config = ext('cpe-config', 'ipdhcp', JSON.stringify(args));
log('Config values from API: ' + JSON.stringify(config));
if (!config) {
log('No config returned from API');
return;
}
let circuitid = config.circuitid; //let circuitid = "AZERTYUIOP";
let idur = config.idur; //let idur = "ZZZZZZ";
let dept= config.dept; //let dept= "000";
let contrat = config.contrat; //let contrat = "azzer";
let abonnement = config.abonnement; //let abonnement = "zeertt";
log('Set Option82 (circuitid) to the CPE value with ' + circuitid);
declare("VirtualParameters.Option82", {value: now}, {value: circuitid});
log('Set Idur to the CPE value with ' + idur);
declare("VirtualParameters.Idur", {value: now}, {value: idur});
log('Set VirtualParameters.contrat with ' + contrat);
declare("VirtualParameters.contrat", {value: now}, {value: contrat});
log('Set VirtualParameters.dept with ' + dept);
declare("VirtualParameters.dept", {value: now}, {value: dept});
log('Set VirtualParameters.abo with ' + abonnement);
declare("VirtualParameters.abo", {value: now}, {value: abonnement});
log('Set Tags.Provisioned');
declare("Tags.Basic_Provisioned", null, {value: true});
return;
My ext script
//genieacs/config/ext/cpe-config.js
// From https://github.com/genieacs/genieacs/wiki/Example-of-a-Provisioning-Flow
"use strict"
console.log("Run cpe-config.js");
const API_URL = 'http://10.75.10.205:1880/rest/v1/';
const url = require("url");
const http = require(API_URL.split(":", 1)[0]);
function ipdhcp(args, callback) {
let params = JSON.parse(args[0]);
const uri = API_URL + "ipdhcp?ip=" + params.ip + '&mac=' + params.mac;
console.log({ uri: uri, ip: params.ip, mac: params.mac });
let options = url.parse(uri);
options.headers = {
accept: 'application/json',
"content-type": 'application/json'
};
let request = http.get(options, function (response) {
console.log("response statusCode: " + response.statusCode);
if (response.statusCode == 404) {
console.log("Get Error code 404");
return callback(null, null);
}
if (response.statusCode >= 400) {
console.log("Get Error code >= 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 () {
let result = JSON.parse(data);
console.log('Returning data to client', result);
return callback(null, result);
});
});
request.on("error", function (err) {
console.log('args');
console.log(arguments);
callback(err);
});
}
exports.ipdhcp = ipdhcp;
My errors
2021-06-15T08:21:40.795Z [INFO] 172.16.75.202 001733-NB7%20Gateway-XU1009020878440350: Script: Start provision script
2021-06-15T08:21:40.843Z [INFO] 172.16.75.202 001733-NB7%20Gateway-XU1009020878440350: Script: Args {"ip":"z.z.z.z","mac":"Z.Z.Z.Z.Z"}
2021-06-15T08:21:40.843Z [INFO] 172.16.75.202 001733-NB7%20Gateway-XU1009020878440350: Script: Launch ext script
2021-06-15T08:21:40.976Z [INFO] 172.16.75.202 001733-NB7%20Gateway-XU1009020878440350: Script: Config values from API: {"dept":"000","idur":"AZERTY","updatetime":"2021-06-14T23:35:27.000Z","circuitid":"AZERTYUIOP","contrat":"ccccc","abonnement":"cccccc","ip":"z.z.z.z","mac":"z.z.Z.z.z"}
2021-06-15T08:21:40.977Z [INFO] 172.16.75.202 001733-NB7%20Gateway-XU1009020878440350: Script: Set Option82 (circuitid) to the CPE value with AZERTYUIOP
2021-06-15T08:21:40.977Z [INFO] 172.16.75.202 001733-NB7%20Gateway-XU1009020878440350: Script: Set Idur to the CPE value with eeeeee
2021-06-15T08:21:40.977Z [INFO] 172.16.75.202 001733-NB7%20Gateway-XU1009020878440350: Script: Set VirtualParameters.contrat with zzzzzz
2021-06-15T08:21:40.977Z [INFO] 172.16.75.202 001733-NB7%20Gateway-XU1009020878440350: Script: Set VirtualParameters.dept with 0000
2021-06-15T08:21:40.977Z [INFO] 172.16.75.202 001733-NB7%20Gateway-XU1009020878440350: Script: Set VirtualParameters.abo with ZZZZ
2021-06-15T08:21:40.977Z [INFO] 172.16.75.202 001733-NB7%20Gateway-XU1009020878440350: Script: Set Tags.Provisioned
2021-06-15T08:21:40.992Z [INFO] 172.16.75.202 001733-NB7%20Gateway-XU1009020878440350: Script: Start VirtualParameters.contrat script
2021-06-15T08:21:40.993Z [INFO] 172.16.75.202 001733-NB7%20Gateway-XU1009020878440350: Script: Start VirtualParameters.dept script
2021-06-15T08:21:40.993Z [INFO] 172.16.75.202 001733-NB7%20Gateway-XU1009020878440350: Script: Start VirtualParameters.Option82 script
2021-06-15T08:21:40.993Z [INFO] 172.16.75.202 001733-NB7%20Gateway-XU1009020878440350: Script: Start VirtualParameters.Idur script
2021-06-15T08:21:40.993Z [INFO] 172.16.75.202 001733-NB7%20Gateway-XU1009020878440350: Script: Start VirtualParameters.abo script
2021-06-15T08:21:41.009Z [INFO] 172.16.75.202 001733-NB7%20Gateway-XU1009020878440350: ACS request; acsRequestId="17a0ec306a80200" acsRequestName="GetParameterValues"
[spoiler]
2021-06-15T08:21:41.011Z [ERROR] 172.16.75.202 001733-NB7%20Gateway-XU1009020878440350: Connection dropped
2021-06-15T08:21:41.011Z [WARN] 172.16.75.202 001733-NB7%20Gateway-XU1009020878440350: Channel has faulted; channel="default" retries=0 faultCode="session_terminated" faultMessage="The TR-069 session was unsuccessfully terminated"
2021-06-15T08:21:41.011Z [WARN] 172.16.75.202 001733-NB7%20Gateway-XU1009020878440350: Channel has faulted; channel="inform" retries=0 faultCode="session_terminated" faultMessage="The TR-069 session was unsuccessfully terminated"
2021-06-15T08:21:41.011Z [WARN] 172.16.75.202 001733-NB7%20Gateway-XU1009020878440350: Channel has faulted; channel="Provisioning" retries=0 faultCode="session_terminated" faultMessage="The TR-069 session was unsuccessfully terminated"
[/spoiler]
Thanks for your help
Laurent