Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Server Error on Startup #10

Open
itsMohammadHeidari opened this issue Dec 20, 2023 · 2 comments
Open

API Server Error on Startup #10

itsMohammadHeidari opened this issue Dec 20, 2023 · 2 comments

Comments

@itsMohammadHeidari
Copy link

Description

When starting the hepsub-cgrates project using the command nodejs cgrates.js, the API server starts, but immediately logs an error related to the registration API.

Expected Behavior

The API server should start without any errors, and it should successfully register with the backend service.

Actual Behavior

The API server starts and logs the following output and error:

API Server started 18088
REGISTER API ERROR 400 Bad Request

Configuration

Here is the relevant portion of the config.js file:

var config = {

  backend: 'http://localhost:9080/api/v3/agent/subscribe',

  token: 'gMjKsDIEnoBYuRlGJJLRyTHZZBNIvbcMHDVgcetKWvfbptajLyAMqWUOIHCZJmwcucSDRsILYmZfXaDY',

  service: {

    "uuid": Math.random().toString(36).substring(7),

    "host":"127.0.0.1",

    "port": 18088,

    "protocol": "http",

    "path": "/get",

    "type": "cdr",

    "ttl": 300,

    "node": "cgrates",

    "gid": 10

  },

  debug: true,

  cgrates: {

    "url": "http://192.168.0.115:2080/jsonrpc",

    "tenant": "cgrates.org",

    "hep_field": "callid"

  }

};

Environment

Please advise on any steps that can be taken to resolve this error.
Thank you!

@lmangani
Copy link
Member

@itsMohammadHeidari please provide the homer-api logs as well. The issue is most likely there (assuming the token was valid)

@itsMohammadHeidari
Copy link
Author

Dear Lorenzo, I appreciate your fast reply.

I've included my curl request, the homer panel's "Auth Token" section's screenshot, and the logs from the "sipcapture/webapp" container below:

curl --location 'http://192.168.0.30:9080/api/v3/agent/subscribe' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Auth-Token: 084ade9c-107f-4ab7-94d3-46832519d98c' \
--data '{
    "uuid": "c8b94a15-bf87-435d-8e2a-c18fc7a0641a",
    "host": "192.168.0.30",
    "port": 18088,
    "protocol": "http",
    "path": "",
    "type": "cdr",
    "ttl": 300,
    "node": "cgrates",
    "gid": 10
}'
time="2023-12-23T07:22:32Z" level=info msg="SELECT * FROM \"auth_token\"  WHERE (expire_date > NOW() AND active = true AND token = $1 )" module=gorm type=sql
time="2023-12-23T07:22:32Z" level=info msg="SELECT count(*) FROM \"auth_token\"  WHERE (expire_date > NOW() AND active = true AND token = $1 )" module=gorm type=sql

Screenshot from 2023-12-23 11-13-16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants