Integration with external http server

dear all …
I just start playing with tr-069 and genieacs.

I use GitHub - genieacs/genieacs-sim: TR-069 client simulator for GenieACS to make first test.
I start it and got

 bino@corobalap  ~/Documents/aku/genieacs-sim   master  ./genieacs-sim -u http://192.168.56.102:7547
Simulator 000000 started
Simulator 000000 listening for connection requests on http://192.168.56.1:53345/

When I open 192.168.56.102:3000/#!/devices/202BC1-BM632w-000000
I got

actualy, I plan to integrate this Genieacs to my application that take care of Radius.
so I read Passing Arguments to an external script

my ext script looks like:

const API_URL = process.env.API_URL || 'http://192.168.56.1:8080';
const url = require("url");
const http = require(API_URL.split(":", 1)[0]);

function resetPppoe(args, callback) {
    console.log('args');

    let params = JSON.parse(args[0]);

    const uri = API_URL + "/ResetPPPoECreds?serial=" + params.serial + '&productClass=' + params.productClass + '&oui=' + params.oui;

    console.log({ uri: uri, serial: params.serial });

    let options = url.parse(uri);
    options.headers = {
        accept: 'application/json',
        "content-type": 'application/json'
    };

    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 resetting PPPoE credentials. 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 credentials to client', result);
            return callback(null, result);
        });
    });

    request.on("error", function (err) {
        console.log(arguments);
        callback(err);
    });
}

exports.resetPppoe = resetPppoe;

My provision looks like

const serial = declare('DeviceID.SerialNumber', {value: 1}).value[0];
const productClass = declare('DeviceID.ProductClass', {value: 1}).value[0];
const oui = declare('DeviceID.OUI', {value: 1}).value[0];
const deviceId = declare('DeviceID.ID', {value: 1}).value[0];
const params = {serial, productClass, oui, deviceId};

let config = ext('resetpppoe', 'resetPppoe', JSON.stringify(params));

log(JSON.stringify(config));

my preset :

name : bino_boot_01
channel : bootstrap
weight: 0
Events: 0 BOOTSTRAP

provision: bino01

a simple python http server that will receive request from genieacs like:

from http.server import BaseHTTPRequestHandler, HTTPServer
import time

hostName = "192.168.56.1"
serverPort = 8080

class MyServer(BaseHTTPRequestHandler):
    def do_GET(self):
        print(f'path:{self.path}')
        self.send_response(200)
        self.send_header("Content-type", "text/html")
        self.end_headers()
        self.wfile.write(bytes("<html><head><title>https://pythonbasics.org</title></head>", "utf-8"))
        self.wfile.write(bytes("<p>Request: %s</p>" % self.path, "utf-8"))
        self.wfile.write(bytes("<body>", "utf-8"))
        self.wfile.write(bytes("<p>This is an example web server.</p>", "utf-8"))
        self.wfile.write(bytes("</body></html>", "utf-8"))

if __name__ == "__main__":        
    webServer = HTTPServer((hostName, serverPort), MyServer)
    print("Server started http://%s:%s" % (hostName, serverPort))

    try:
        webServer.serve_forever()
    except KeyboardInterrupt:
        pass

    webServer.server_close()
    print("Server stopped.")

That http server run from my terminal
I restart that GenieAcs-Simulator, but my python http server did not receive any request

Kindly please tell me what todo to fix this problem

What is the point of the pipes if you can use the second part directly ? At least during testing …

Why are you doing this? if your plan is to switch to https you should simply use https directly.

Ensure you can actually access your webpage.

What I did at the time was to start playing with the example provided by the documentation.


also check your logs to see what could be wrong.;

on debian, derivated and and similars

journalctrl | grep cwmp

or the name of your extension instead of “cwmp”

on slackware and derivated:

cat /var/log/messages | grep cwmp

thankyou for your response.

I re copy external script from Example of a Provisioning Flow · genieacs/genieacs Wiki · GitHub

just change the first 3 line to be

const API_URL = 'http://127.0.0.1:8080/api';
const url = require("url");
const http = require("http");

I move my python script to same host as genieacs, just to make sure there is no firewall problem.

genieacs@genieacs:/home/bino$ curl http://127.0.0.1:8080/api
<html><head><title>https://pythonbasics.org</title></head><p>Request: /api</p><body><p>This is an example web server.</p></body></html>

restart my genieacs-sim


 ✘ bino@corobalap  ~/Documents/aku/genieacs-sim   master  ./genieacs-sim -u http://192.168.56.102:7547

Simulator 000000 started
Simulator 000000 listening for connection requests on http://192.168.56.1:55173/

still my python http server got no request.

from tailing /var/log/genieacs/genieacs-cwmp-access.log , I always get line like

2023-03-31T14:06:16.804Z [INFO] ::ffff:192.168.56.1 202BC1-BM632w-000000: Inform; cpeRequestId="la5w4io6" informEvent="2 PERIODIC" informRetryCount=0

every time i start the genieacs simulator, but with different cpeRequestId value.

and /var/log/genieacs/genieacs-debug.yaml says:

event: incoming HTTP request
timestamp: 2023-03-31T14:27:21.595Z
remoteAddress: "::ffff:192.168.56.1"
deviceId: 202BC1-BM632w-000000
connection: 2023-03-31T14:27:21.595Z
localPort: 7547
method: POST
url: /
headers: 
  content-length: "2069"
  content-type: text/xml; charset="utf-8"
  authorization: Basic OEtBOFdBMTE1MTEwMDA0Mzo=
  host: 192.168.56.102:7547
  connection: keep-alive
body: >-
  <?xml version="1.0" encoding="UTF-8"?>

  <soap-env:Envelope xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:cwmp="urn:dslforum-org:cwmp-1-0"><soap-env:Header><cwmp:ID
  soap-env:mustUnderstand="1">pv8djjuy</cwmp:ID></soap-env:Header><soap-env:Body><cwmp:Inform><DeviceId><Manufacturer>Huawei
  Technologies Co.,
  Ltd.</Manufacturer><OUI>202BC1</OUI><ProductClass>BM632w</ProductClass><SerialNumber>000000</SerialNumber></DeviceId><Event
  soap-enc:arrayType="cwmp:EventStruct[1]"><EventStruct><EventCode>2
  PERIODIC</EventCode><CommandKey/></EventStruct></Event><MaxEnvelopes>1</MaxEnvelopes><CurrentTime>2023-03-31T14:27:21.577Z</CurrentTime><RetryCount>0</RetryCount><ParameterList
  soap-enc:arrayType="cwmp:ParameterValueStruct[16]"><ParameterValueStruct><Name>InternetGatewayDevice.DeviceInfo.SpecVersion</Name><Value
  xsi:type="xsd:string">1</Value></ParameterValueStruct><ParameterValueStruct><Name>InternetGatewayDevice.DeviceInfo.HardwareVersion</Name><Value
  xsi:type="xsd:string">40501</Value></ParameterValueStruct><ParameterValueStruct><Name>InternetGatewayDevice.DeviceInfo.SoftwareVersion</Name><Value
  xsi:type="xsd:string">V100R001IRQC56B017</Value></ParameterValueStruct><ParameterValueStruct><Name>InternetGatewayDevice.DeviceInfo.ProvisioningCode</Name><Value
  xsi:type="xsd:string"/></ParameterValueStruct><ParameterValueStruct><Name>InternetGatewayDevice.ManagementServer.ParameterKey</Name><Value
  xsi:type="xsd:string"/></ParameterValueStruct><ParameterValueStruct><Name>InternetGatewayDevice.ManagementServer.ConnectionRequestURL</Name><Value
  xsi:type="xsd:string">http://192.168.56.1:45851/</Value></ParameterValueStruct><ParameterValueStruct><Name>InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress</Name><Value
  xsi:type="xsd:string">172.3.89.139</Value></ParameterValueStruct></ParameterList></cwmp:Inform></soap-env:Body></soap-env:Envelope>
---
event: outgoing HTTP response
timestamp: 2023-03-31T14:27:21.598Z
remoteAddress: "::ffff:192.168.56.1"
deviceId: 202BC1-BM632w-000000
connection: 2023-03-31T14:27:21.595Z
statusCode: 200
headers: 
  content-length: 528
  server: GenieACS/1.2.9+20220822165235
  soapserver: GenieACS/1.2.9+20220822165235
  content-type: text/xml; charset="utf-8"
  set-cookie: session=cb73a374a0a2c2c2
body: >-
  <?xml version="1.0" encoding="UTF-8"?>

  <soap-env:Envelope xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:cwmp="urn:dslforum-org:cwmp-1-0"><soap-env:Header><cwmp:ID
  soap-env:mustUnderstand="1">pv8djjuy</cwmp:ID></soap-env:Header><soap-env:Body><cwmp:InformResponse><MaxEnvelopes>1</MaxEnvelopes></cwmp:InformResponse></soap-env:Body></soap-env:Envelope>
---
event: incoming HTTP request
timestamp: 2023-03-31T14:27:21.604Z
remoteAddress: "::ffff:192.168.56.1"
deviceId: 202BC1-BM632w-000000
connection: 2023-03-31T14:27:21.595Z
localPort: 7547
method: POST
url: /
headers: 
  content-length: "0"
  content-type: text/xml; charset="utf-8"
  authorization: Basic OEtBOFdBMTE1MTEwMDA0Mzo=
  cookie: session=cb73a374a0a2c2c2
  host: 192.168.56.102:7547
  connection: keep-alive
body: ""
---
event: outgoing HTTP response
timestamp: 2023-03-31T14:27:21.642Z
remoteAddress: "::ffff:192.168.56.1"
deviceId: 202BC1-BM632w-000000
connection: 2023-03-31T14:27:21.595Z
statusCode: 204
headers: 
  content-length: 0
  server: GenieACS/1.2.9+20220822165235
  soapserver: GenieACS/1.2.9+20220822165235
  connection: close
body: ""

argh …
I thing some how the simulator didn’t send event ‘0 BOOTSTRAP’.
I change my preset ‘event’ from ‘0 BOOTSTRAP’ to ‘2 PERIODIC’ and my python http server start to receive request.