Picture of Uwe 2460
Registered 9 years 196 days
Uwe 2460 Monday, 27 September 2021, 10:22 AM
mt:WriteConfig to fax app service is not answered
Hello everyone,

I’m trying to extend our PBX rollout automation. SMTP settings have been added in V13R2 to fax app, so I’m trying to configure this now also during rollout.

This settings are manually configured with PBX Manager plugin. Same applies to contacts app settings. I can configure contacts app settings with direct login to contacts app service and sending „mt“:„WriteConfig“ WebSocket messages.
But trying this with fax app service, I do not get any response from fax app service:

Example of message flow:
==> {"mt":"AppChallenge"}
<== {"mt":"AppChallengeResult","challenge":"1a9eb3d56c5a2d34"}
==> {"mt":"AppLogin","app":"innovaphone-fax","domain":"vpbx.myadmin.cloud","sip":"fax","guid":"00000000000000000000000000000000","dn":"fax","digest":"da3e01ce59ac36ef91321ce83e57a9600551d92e7e3b7fae2886cd2d110c7f22","pbxObj":"fax"}
<== {"mt":"AppLoginResult","app":"innovaphone-fax","ok":true}
==> {"mt":"WriteConfig","api":"Config","ConfigItems":{"pbxReplicationFilter":"v13test","smtpHost":"v13test.vpbx.myadmin.cloud","smtpServer":"10.20.20.7","smtpUser":"","smtpSenderName":"Fax Service v13test","smtpSenderAddress":"no-reply@v13test.vpbx.myadmin.cloud","smtpPassword":{"value":"","key":"RIAekdCM5_5q"},"mailSubjectIncoming":"","mailHtmlBodyIncoming":""},"src":"FaxSettingsAutomaton"}
After this, there is no response.

Some logs of fax app service (V13R2 SR4):
fax@v13test.vpbx.myadmin.cloud WebserverPlugin(025c46a0,025e9380)::WebserverPluginWebsocketListenResult(): path = /innovaphone-fax, registeredPathForRequest = , host = 192.168.52.80
fax@v13test.vpbx.myadmin.cloud AppWebsocket(025ebca0)::AppWebsocket
fax@v13test.vpbx.myadmin.cloud WebserverPlugin(025c46a0,025e9380)::WebsocketAccept(): user = 0x025ebca0
fax@v13test.vpbx.myadmin.cloud WebserverPlugin(connection id: 1100)::WebsocketAccept() request accepted
fax@v13test.vpbx.myadmin.cloud AppWebsocket(025ebca0)::AppWebsocketRecv
fax@v13test.vpbx.myadmin.cloud AppWebsocket(025ebca0)::WebsocketSendResult() connected=0 sendCount=0
fax@v13test.vpbx.myadmin.cloud FaxSession::AppWebsocketConnectComplete vpbx.myadmin.cloud fax 00000000000000000000000000000000 innovaphone-fax right: 00
fax@v13test.vpbx.myadmin.cloud AppWebsocket(025ebca0)::WebsocketSendResult() connected=1 sendCount=1
fax@v13test.vpbx.myadmin.cloud AppWebsocket(025ebca0)::AppWebsocketRecvResult {"mt":"WriteConfig","api":"Config","ConfigItems":{"pbxReplicationFilter":"v13test","smtpHost":"v13test.vpbx.myadmin.cloud","smtpServer":"10.20.20.7","smtpUser":"","smtpSenderName":"Fax Service v13test","smtpSenderAddress":"no-reply@v13test.vpbx.myadmin.cloud","smtpPassword":{"value":"","key":"RIAekdCM5_5q"},"mailSubjectIncoming":"","mailHtmlBodyIncoming":""},"src":"FaxSettingsAutomaton"}
fax@v13test.vpbx.myadmin.cloud FaxSession::AppWebsocketApiPermission API Config, admin 0 pbx 0
fax@v13test.vpbx.myadmin.cloud AppWebsocket(025ebca0)::AppWebsocketMessageComplete connected:true
fax@v13test.vpbx.myadmin.cloud AppWebsocket(025ebca0)::AppWebsocketClosed
fax@v13test.vpbx.myadmin.cloud AppWebsocket(025ebca0)::~AppWebsocket

What am I missing?

Kind regards
Uwe

Andreas Fink
Moderator Registered 13 years 52 days
Andreas Fink (innovaphone) Tuesday, 28 September 2021, 08:29 AM
Re: mt:WriteConfig to fax app service is not answered
Hello Uwe,

it seems the element 'smtpPassword' is not encrypted in proper way.

JSON Elements in the Config API ending with 'Password' must be encrypted to neet requirements described here:
https://sdk.innovaphone.com/13r2/sdk/common/lib/config.htm#WriteConfig

You can also check client side implementation of this encryption:
https://sdk.innovaphone.com/13r2/web1/config/config.htm


web/config/innovaphone.config.js:
function save()
{
var data = {};
var names = Object.keys(itemInfos);
for (var i = 0; i < names.length; ++i) {
var curItem = itemInfos[names[i]];
if (curItem.password == true) {
if (curItem.changed == true) {
var seed = Math.random().toString(36);
data[curItem.name] = { value: appWebsocket.encrypt(seed, that[curItem.name]), key: seed };
}
}
else data[curItem.name] = that[curItem.name];
}

console.log("Data = " + JSON.stringify(data));
appWebsocket.send({
"api": "Config",
"mt": "WriteConfig",
"ConfigItems": data });
}

Best Regards
Andreas Fink
Picture of Uwe 2460
Registered 9 years 196 days
Uwe 2460 Wednesday, 29 September 2021, 10:26 AM
Re: mt:WriteConfig to fax app service is not answered
Hello Andreas,

thanks for having a look at this!
I use the same encryption function, that works for Contacts (WriteConfig) and UsersAdmin (CheckPassword) WebSocket messages. I hope, that Fax app service is not using different encryption.

The example above did not have a SMTP user or password set. So only the random seed is part of the element “smtpPassword”. The WriteConfig message looks similar to configuration via PBX Manager, when no SMTP password is set.
I now additionally tried with configured SMTP password and also without element “smtpPassword” at all. I always ran into timeout (no response).

Just an idea:
What I cannot see in Contacts app service log, but in above Fax app service log, are following lines:
fax@v13test.vpbx.myadmin.cloud FaxSession::AppWebsocketConnectComplete vpbx.myadmin.cloud fax 00000000000000000000000000000000 innovaphone-fax right: 00
fax@v13test.vpbx.myadmin.cloud FaxSession::AppWebsocketApiPermission API Config, admin 0 pbx 0
“…Permission”- or “right”-parameters with “0” values do not look good to me. What do they mean?
At time of Fax app (or any other app) service configuration, there exists no customer PBX. The customer PBX is created later, after all customer devices configurations and app services instances are successfully created and configured. Could this be the problem?

Shortly: What is Fax app service doing different to Contacts app service with “mt”:“WriteConfig” messages?

best regards
Uwe
Andreas Fink
Moderator Registered 13 years 52 days
Andreas Fink (innovaphone) Wednesday, 29 September 2021, 12:08 PM
Re: mt:WriteConfig to fax app service is not answered
Hello Uwe,

it seems the Fax App has special handling for the WebSocket connections from PBX Manager Plugin, that allows WriteConfig only if the app name was set to "-".

The Solution would be to use following AppLogin message:

{"mt":"AppLogin","app":"-", ...

In general it is useful to compare the JSON messages from the original app against your implementation, to see differences that may affect the functionality.

Best Regards
Andreas
Picture of Uwe 2460
Registered 9 years 196 days
Uwe 2460 Wednesday, 29 September 2021, 03:36 PM
Re: mt:WriteConfig to fax app service is not answered
Hello Andreas,

in this case, the AP Platform does not know, to what app service I want to login:
==> {"mt":"AppChallenge"}
<== {"mt":"AppChallengeResult","challenge":"332e526c40e8b649"}
==> {"mt":"AppLogin","app":"-","domain":"vpbx.myadmin.cloud","sip":"fax","guid":"00000000000000000000000000000000","dn":"fax","digest":"f36a46d9eaabf8b4d5c4b10d767f88830e10c6b46ad14b734641e692bfe459ea","pbxObj":"fax"}
<== {"mt":"AppLoginResult","app":"-","FAX-WS":"Login"}
(means login failed)

I think you are referring to the Admin user login to PBX / PBX Manager, that can be seen in browser console.
I was told here and in updated wiki article, not to login as user to PBX for automation purposes: https://class.innovaphone.com/moodle2/mod/forum/discuss.php?d=26186#p72255
Unfortunately there is not even a PBX at this point of rollout.

So the current main question is, should it generally be possible to configure SMTP parameters with direct fax app service login?

Kind regards
Uwe

Picture of Uwe 2460
Registered 9 years 196 days
Uwe 2460 Tuesday, 12 October 2021, 12:47 PM in response to Andreas Fink (innovaphone)
Re: mt:WriteConfig to fax app service is not answered
Hello Andreas,

unfortunately this is not working with direct login to fax app service (see above).
Do you have any idea, how to proceed?

kind regards
Uwe
Andreas Fink
Moderator Registered 13 years 52 days
Andreas Fink (innovaphone) Thursday, 18 November 2021, 01:24 PM
Re: mt:WriteConfig to fax app service is not answered
Hello Uwe,

if you have no PBX at the moment of the config deployment to the app instance, you have to login using AP Manager password.

  • Open websocket to ws://APManagerHost/fax and do AppLogin with following parameters:
    • app="-" (required to be able to write config)
    • sip="fax" (name of the instance)
    • domain="example.com"
    • guid="123456789012" (must have specific length, otherwise DB error)
    • dn="Fax" (optional, as i know)
    • password="<APManagerPassword><FaxAppInstancePassword>"
  • Now you should be able to read config:
    • {"api": "Config", "mt":"ReadConfig"}
  • Or write it (encrypt password first at WS object):
    • {"api": "Config", "mt": "WriteConfig", "ConfigItems": {
      "smtpHost": "faxhost",
      "smtpServer": "smtp.example.com",
      "smtpUser": "Testmail",
      "smtpPassword": { "value": "{$pwdTestSmtpEnc}", "key":"Testfax"},
      "smtpSenderAddress": "testfax@example.com",
      "smtpSenderName": "Test Fax Service" }}
  • And get WriteConfigResult:
    • {"api": "Config", "mt": "WriteConfigResult", "result": "ok"}
EDIT: it must be Fax App instance password, not AP Manager password in this case. My apologies for wrong information!

Best Regards
Andreas Fink
Picture of Uwe 2460
Registered 9 years 196 days
Uwe 2460 Monday, 18 October 2021, 05:33 PM
Re: mt:WriteConfig to fax app service is not answered
Hallo Andreas,

when I use wss://APManagerHost/fax, then I get timeout.

When I use wss://APManagerHost/domain/fax, then I get a WebSocket connection.
But unfortunately I do not get a login with AP Manager password. The domain I use, ist the domain of fax app instance.
As password is not used directly, I use the following string template for digest calculation (same as for other App service logins).
<app>:<domain>:<sip>:<guid>:<dn>:<challenge>:<password>
"-:v13test.vpbx.myadmin.cloud:fax:0123456789abcdef0123456789abcdef:Fax:77ec7e95023a052d:<password>"

Full message flow:
==> {"mt":"AppChallenge"}
<== {"mt":"AppChallengeResult","challenge":"77ec7e95023a052d"}
==> {"mt":"AppLogin",
"app":"-",
"domain":"v13test.vpbx.myadmin.cloud",
"sip":"fax",
"guid":"0123456789abcdef0123456789abcdef",
"dn":"fax",
"digest":"986ec4c94b6a22fa96ba0202cd2da018758a634fcb0933f7fbbb68a974a6ef6a"}
<== {"mt":"AppLoginResult","app":"-"}

There is still something wrong, maybe the WebSocket URI?

Kind regards
Uwe

Andreas Fink
Moderator Registered 13 years 52 days
Andreas Fink (innovaphone) Friday, 5 November 2021, 08:48 PM
Re: mt:WriteConfig to fax app service is not answered
Hello Uwe,

maybe you are using different algorithm to calculate digest?

Here our implementation, in case AP manager password is used to login directly at the App Service:
function passwordLogin(challenge) {
var obj = {};
obj.app = app;
obj.sip = app;
obj.domain = domain ? domain : "";
obj.lang = "en";
obj.guid = "00000000000000000000000000000000";
obj.dn = "Admin";
obj.digest = innovaphone.crypto.sha256(app + ":" + obj.domain + ":" + obj.sip + ":" + obj.guid + ":" + obj.dn + ":" + challenge + ":" + password);
obj.key = innovaphone.crypto.sha256("innovaphoneAppSessionKey:" + challenge + ":" + password);
login(obj);
}

Here a login sequence (with the digest calculated as implemented in the passwordLogin function of innovaphone.appwebsocket.Connection.js):

var appwebsocket = AppWebsocketClient.connect("wss://172.16.0.123/test.com/fax", "pwd", "-", "test.com", "fax", "123456789012", "Fax");

==> {"mt":"AppChallenge"}
<== {"mt":"AppChallengeResult","challenge":"5b3b18cf4aa57c48"}
==> {"mt": "AppLogin", "app": "-", "dn": "Fax", "domain": "test.com", "guid": "123456789012", "sip": "fax", "digest": "788c30055ed7d6d3a7b5e6ce0f264457708490c961530ca4cce032e541e7a1f3"
}
<== {"mt":"AppLoginResult","app":"-","ok":true}

The URI I use here is the "Webserver path" of the Fax App instance.

The password is the default AP Manager password "pwd".

Best Regards
Andreas Fink
Picture of Uwe 2460
Registered 9 years 196 days
Uwe 2460 Thursday, 18 November 2021, 11:03 AM
Re: mt:WriteConfig to fax app service is not answered
Hi Andreas,

this raises unfortunately more questions than answers.

I understand, that wss://APManagerHost/domain/fax is the required URI.
But what is the value of „app“ in your mentioned digest calculation? Is it „-“, „fax“, „Fax“ or „innovaphone-fax”? I tried every value without success.

Even more confusing:
Guid in your digest calculation is „00000000000000000000000000000000“ but in mt:AppLogin „123456789012“?
Dn in digest calculation is „Admin“ but in mt:AppLogin it is „Fax“?
However, I tried all imaginable combinations without success (no login).

I have now already spent many hours on this tiny problem. I think I will participate in one of the next Friday SDK community meetings, to address this issue.

kind regards
Uwe
Andreas Fink
Moderator Registered 13 years 52 days
Andreas Fink (innovaphone) Thursday, 18 November 2021, 12:04 PM
Re: mt:WriteConfig to fax app service is not answered
Hello Uwe,

> I understand, that wss://APManagerHost/domain/fax is the required URI.

Yes, this is the webserver path configured on the instance of the Fax app.

> But what is the value of „app“ in your mentioned digest calculation? Is it „-“, „fax“, „Fax“ or „innovaphone-fax”? I tried every value without success.

It is "-", as in my example. This is important to be able to change settings of the instance via WebSocket.

> Even more confusing:
> Guid in your digest calculation is „00000000000000000000000000000000“ but
> in mt:AppLogin „123456789012“?
> Dn in digest calculation is „Admin“ but in mt:AppLogin it is „Fax“?
> However, I tried all imaginable combinations without success (no login).

The guid has to have some specific min length, but is not validated in case of login to the instance. So you can use both values.

The Dn is also not validated against any values of the Fax app instance, but must exist.

However, the values are used to calculate the digest:
obj.digest = innovaphone.crypto.sha256(app + ":" + obj.domain + ":" + obj.sip + ":" + obj.guid + ":" + obj.dn + ":" + challenge + ":" + password);


In my example from previous post, I was using C++ AppWebsocket implementation to generate the WebSocket JSON messages, but have posted the JS implementation of the passwordLogin function just to show you the digest calculation. I'm sorry for the misleading, but both of the implementations are correct, with the difference, that in JS "Admin" is used as dn.

To make sure, your digest calculation is correct, please test it with input data from my example (challenge 5b3b18cf4aa57c48). Just create a synthetic test and see, if you get the same digest.

Best Regards
Andreas Fink
Andreas Fink
Moderator Registered 13 years 52 days
Andreas Fink (innovaphone) Thursday, 18 November 2021, 01:28 PM
1 of 1 users consider this post helpful
Re: mt:WriteConfig to fax app service is not answered
The reason it was not working, is my wrong information about password - it must be instance password, not AP manager password.

My apologies for this mistake.

Best Regards
Andreas
Picture of Uwe 2460
Registered 9 years 196 days
Uwe 2460 Thursday, 18 November 2021, 03:29 PM
Re: mt:WriteConfig to fax app service is not answered
Hi Andreas,

thanks for the remote session. Login and fax configuration now works with instance password and app="-"

best regards
Uwe
Picture of Uwe 2460
Registered 9 years 196 days
Uwe 2460 Monday, 25 October 2021, 03:19 PM in response to Andreas Fink (innovaphone)
Re: mt:WriteConfig to fax app service is not answered
Hello Andreas,

I'm trying it with an shorter answer now wink

When I use the proposed wss://APManagerHost/fax, then I get no WebSocket connection established (timeout).

kind regards
Uwe

Picture of Marc Schodermayr (innovaphone)
Moderator Registered 9 years 201 days
Marc Schodermayr (innovaphone) Tuesday, 28 September 2021, 09:00 AM in response to Uwe 2460
Re: mt:WriteConfig to fax app service is not answered
Hello Uwe,

you may send the config message on your own. However, as long as there is no really good reason to implement it by your own, it is highly recommended to use the innovaphone.config.js implementation, it will make your life easier (regarding the config reading / writing of yourse. wink ). The documentation posted by Andreas shows how to implement / use it.

Picture of Uwe 2460
Registered 9 years 196 days
Uwe 2460 Wednesday, 29 September 2021, 10:39 AM
Re: mt:WriteConfig to fax app service is not answered
Hello Marc,

you are definitely right. Using existing innovaphone JavaScript implementation, would make live much easier.

Unfortunately there are really some reasons, that prevent us from doing so immediately:
There is an existing C# project, that is doing V12- and complete V13-cloud PBX rollout.
The result of V13-cloud PBX rollout is similar to innovaphone “Install”. And there are some additional things like configuration of DNS server, creating VMware guest machine, configuring reverse-proxies, license server, update server, SMTP relay server, SSH interface … already implemented.

Switching completely and immediately to JavaScript is beyond all imagination. Embedding JavaScript in existing C# code would cost at least investigation-, implementation- and test-efforts.
It is currently just the V13R2 fax setting that we are missing sad

kind regards
Uwe
← You can define your color theme preference here