Picture of Wim 4127
Registered 6 years 124 days
Wim 4127 Tuesday, 18 April 2023, 05:33 PM
SetInstancePassword message from C++ service
Hi, I have an urgent request. In a PBX manager plugin one can send a message SetInstancePassword via the manager api. I want to do the same in our C++ backend. I know the structure of the message, but, to which application must I send this message. I send it to the "apps" because that is the ap manager where I get all information about the app instances on the app platform, but, that doesn't seem to respond on this message... so I guess it should be send to another app? The message I send from my backend is exactly the same as the one send in the front end, so the message structure and content is correct.

Please advise... this is blocking us for the moment
Andreas Fink
Moderator Registered 12 years 289 days
Andreas Fink (innovaphone) Wednesday, 19 April 2023, 06:03 PM
Re: SetInstancePassword message from C++ service
Hello Wim,

the com.innovaphone.manager API for this purpose is designed as myApps client side API. This means, the apps running inside of myApps client, like PBX manager, can use it by having access to the "ap" app.

The hidden manager app loads an app code from /manager/manager-domain-api.htm and opens a WebSocket connection to the /manager-api. The hidden manager app takes lokal messages (like SetInstancePassword) from the apps running in the myApps client and forwards them to the WebSocket connection (which is terminated in the AP Manager Service running on the AP).

In your case a WebSocket connection from your C++ App Service to ws://host/manager-api on the AP must be established. The authentication would be possible via the AppWebsocket Authenticator Library - this would enable your service to authenticate the Websocket without using shared secret of the AP Manager. Than you could send the API messages into this WS connection and also list all apps/instances installed on the AP.

Best Regards
Andreas Fink




Picture of Wim 4127
Registered 6 years 124 days
Wim 4127 Thursday, 20 April 2023, 05:45 PM
Re: SetInstancePassword message from C++ service
Hi Andreas,

that is what I thought, but, it doesn't work. The instance password is not changed and the ap manager doesn't send me a reply. I am however able to get all instance and service information without a problem, so I think I'm using the right API.

See the attached logfile.

On line 165 and following you can see our client to the ap manager and getting all the service information. It is on session 0x200eb30, and all messages get replied.

On line 721 you see following log 04-20 09:10:33.374 xqting@[example.com ] [MsgContext ] I> 0x200eb30 --> {"mt":"SetInstancePassword","path":"kiwi78.be/vm_nl","pwd":"UF!31eT0kwoQbkvV","src":"APManagerAppClient"}
So I send the SetInstancePassword message to the manager api just like the front-end does... but it is never replied, and, also it is never changed... because when I change it just manually to that value in the AP manager it works fine.

Why isn't this handled?
log.txt
Andreas Fink
Moderator Registered 12 years 289 days
Andreas Fink (innovaphone) Thursday, 20 April 2023, 10:59 PM
Re: SetInstancePassword message from C++ service
Hello Wim,

it could be different URL you are using to connect to the AP manager:

04-20 09:09:08.920 xqting@[example.com ] [InnovaphoneInstance ] I> Service API update received, connecting AP Manager app
04-20 09:09:08.920 xqting@[example.com ] [AppClient ] I> App client set base url for service to https://172.16.0.20/manager

The path "/manager" is usually used by the UI, if you connect to the AP Manager Web Interface. However the API that maintains the message types "SetInstanceDomain", "SetInstancePassword", "GetInstanceLogin" and "SetEmailConfiguration" is located at the path "/manager-api".

Best Regards
Andreas Fink
Picture of Uwe 2460
Registered 9 years 68 days
Uwe 2460 Thursday, 20 April 2023, 10:48 PM in response to Wim 4127
Re: SetInstancePassword message from C++ service
Hi Wim,

just a guess:
“SetInstancePassword“ could be a special local message type (mt) for PBX AP object, when logged in as a PBX myApps client. I haven’t seen it in logs so far(, even if it would be nice to have…).

If you use PBX Manager to change instance passwords, you will see different message types depending on App.
On changing instance password of voicemail App via PBX manager you will see mt “SetUserPassword”.
On changing instance password of contacts App via PBX manager you will see mt “WriteConfig”.
...

When connecting directly to ws://host/manager, I could use mt seen on direct connection to AP manager like: "AddInstance", "StartInstance", "StopInstance", "RemoveInstance”.
Therefore I would use mt "EditInstance" for changing instance password in context of direct AP manager login.

happy reverse engineering wink
and best regards
Uwe

Picture of Wim 4127
Registered 6 years 124 days
Wim 4127 Friday, 21 April 2023, 09:21 AM
Re: SetInstancePassword message from C++ service
When you go to the VM App pbx manager plugin and you do not have any vm's defined yet, you can create a new one. If you look at the browser logs there, when you create the first VM object, it will create the object. For this it actually needs two passwords:
- The password (and username and URL) that must be provided on the "Voicemail" tab (if you use the old v12 interface to look at an object), which comes from the VM app instance and you configure there. This can be fetch by sending a GetUserPassword message to the VM app, which I have and that works.
- However, the VM object also needs an password for the object itself, which must be the same password as the app instance password. This is the password you provide in the General tab of an object.

There is no way to retrieve the instance password, so, what they do in the UI is they generate a new password, then they create a VM object with this password, and then they modify the instance password using the SetInstancePassword message. For the second VM object, they must not do that, because in the update object message one uses to create the object via the admin api, you can set the copyPwd field to the name of an existing object, and then it takes that object's password. This avoids you have to set the instance password again and change the password of all related objects.

So if you want to see the messages in the UI I try to reproduce, just create a first VM object for a specific VM app and you will see a SetInstancePassword message.

I'll try to also do as Uwe suggests and use other message of the AP manager to edit an instance.

Andreas Fink
Moderator Registered 12 years 289 days
Andreas Fink (innovaphone) Monday, 24 April 2023, 11:18 AM
Re: SetInstancePassword message from C++ service
Hello Wim,

i have just tested with the following steps:

Connect to AP Manager via URL ws://127.0.0.1/manager/manager-api

Use "ap" as app name. The App Object of your app must have enabled "ap" on the Apps tab, in order your app can get login for the "ap" app:

send to PBX {"api":"Services","mt":"GetServiceLogin","app":"ap","challenge":"11e939967cb528e4"}
recv from PBX: {"api":"Services","mt":"GetServiceLoginResult","digest":"46a1c7bf...d0fb2e63", ...}

After authentication is done, you can test if the WebSocket connection to the AP Manager API is working by sending message type "ServiceControls":

send to AP: {"mt":"ServiceControls"}
recv from AP: {"mt":"ServiceControlsResult","controls":[...]}

Te set a password of an instance use message type "SetInstancePassword" with "Webserver path" as the instance identifier:
{ mt: "SetInstancePassword", "path": "test.com/instancename", "pwd": "1234567890" }

Best Regards
Andreas Fink
← You can define your color theme preference here