sipcapture / homer-app

HOMER 7.x Front-End and API Server
http://sipcapture.io
GNU Affero General Public License v3.0
204 stars 79 forks source link

HEPsub not working #409

Closed thepacketlover closed 3 years ago

thepacketlover commented 3 years ago

Hello,

I have been trying to start working with the HEPSUB projects. I started looking at the simple sipcapture/hepsub project, in troubleshooting have looked at the hepsub-apiban, hep-sub-elastic, hepsub-rtpengine, hepsub-cgrates projects.

The environment is on a test machine and have tried a fresh install of homer 7 on Centos 7 via the install script in the homer-installer project and also the docker from homer7-docker project. Same results on both installs.

I have updated the config files for with API KEY and correct IPs from the Homer GUI. Each of the sample hepsub- projects all fail with the same message.

I am sure this is something simple I am missing. I have tried to run homer-app in debug logging level but don't get much in the log that can point me to what is wrong.

The subscribe message is:

POST /api/v3/agent/subscribe HTTP/1.1
Auth-Token: e884a4fe-5eb4-412c-b719-491a1607e3db
host: 192.168.176.8:9080
accept: application/json
content-type: application/json
content-length: 170
Connection: close

{"uuid":"47a7b2a0-6a07-11eb-9b12-792fcaae01a6","host":"192.168.176.2","port":18088,"protocol":"http","path":"/get","type":"cdr","ttl":300,"node":"test-endpoint","gid":10}

The response I get is:

HTTP/1.1 400 Bad Request
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=UTF-8
Vary: Origin
Date: Mon, 08 Feb 2021 12:15:06 GMT
Content-Length: 40
Connection: close

{"data":{},"message":"record not found"}

the sample hep-sub app produces

Body: {"url":"http://192.168.176.8:9080/api/v3/agent/subscribe","method":"POST","json":{"uuid":"47a7b2a0-6a07-11eb-9b12-792fcaae01a6","host":"192.168.176.2","port":18088,"protocol":"http","path":"/get","type":"cdr","ttl":300,"node":"test-endpoint","gid":10},"headers":{"Auth-Token":"e884a4fe-5eb4-412c-b719-491a1607e3db"}}

API Server started 18088

REGISTER API ERROR:  record not found

Is there some other setup that needs to be done prior to registering a hepsub endpoint other than creating an API key?

lmangani commented 3 years ago

Hello @thepacketlover and thanks for giving this a try! Could you share your config.js without any sensitive details so I can try replicate this?

thepacketlover commented 3 years ago

Hello, here is the complete file.

var config = {
  backend: 'http://192.168.176.8:9080/api/v3/agent/subscribe',
  token: 'e884a4fe-5eb4-412c-b719-491a1607e3db',
  service: {
        "uuid": Math.random().toString(36).substring(7),
        "host":"192.168.176.2",
        "port": 18088,
        "protocol": "http",
        "path": "/get",
        "type": "cdr",
        "ttl": 300,
        "node": "test-endpoint",
        "gid": 10
  },
  "debug": true
};
lmangani commented 3 years ago

Could you confirm how you created the API Token in hepsub? Was it freshly generated? that's the core issue.

thepacketlover commented 3 years ago

@lmangani In the GUI Settings in upper right. Then AuthToken. There was a test token created on install that us good for 30 days. image

lmangani commented 3 years ago

Oh that's the GUID - its not the actual token! please generate a new one, the token is only displayed once and does not appear afterwards - could this be the source of confusion?

thepacketlover commented 3 years ago

@lmangani That was the issue. I was sure it was something that I was miss understanding. Thank you for the help in getting past this hurdle.

thepacketlover commented 3 years ago

Thank you for the help!

lmangani commented 3 years ago

@thepacketlover its our pleasure, happy to help with anything hepsub related (its still fresh paint)