Picture of Wim 4127
Registered 6 years 310 days
Wim 4127 Sunday, 3 May 2020, 08:36 AM
Replication using basic JSON messages
I've created an external app service by following the tutorial http://sdk.innovaphone.com/doc/tutorials/ExternalAppService.htm. Allthough not written in PHP but in nodejs, this seems to work rather simple and correct for the most APIs such as RCC, PbxAdminApi, etc... So the app is configured correctly, connecting works, permissions are set correctly and permissions are set for each API.

I'm now trying to use the messages as described in http://sdk.innovaphone.com/doc/appwebsocket/Replication.htm (given this is not a C++ app service, the IReplicator as suggested in the other tutorial is not applicable). I do not get this working however, probably because I'm missing something. Following is the communication from and to the PBX, all messages are sent on the web socket connection that is made when getting the PbxInfo message (like in the C++ tutorial). I think all message are according to the documentation, yet, the ReplicateStartResult is not what I would expect it to be:

RECV <= {"mt":"AppChallenge"}
SEND => {"mt":"AppChallengeResult","challenge":"1234"}
RECV <= {"mt":"AppLogin","sip":"ExternalApp","guid":"e7125bb4e0aa5e01381300903340016f","dn":"ExternalApp","digest":"646022a5a5aed17ab3085671d5e4a7287726f75a143a08f362410ed5e7fbb7fd","domain":"xqting.be","app":"monitor","info":{"appobj":"ExternalApp","appurl":"http://10.0.0.101:8080/hub/monitor","cn":"ExternalApp","unlicensed":true,"groups":["monitored"],"apps":[]}}
SEND => {"mt":"AppLoginResult","ok":true}
RECV <= {"mt":"PbxInfo","domain":"xqting.be","pbx":"inno13-pbx","pbxDns":"inno13-pbx.xqting.be","apis":["EpSignal","PbxAdminApi","PbxApi","PbxMessages","PbxSignal","PbxTableUsers","RCC","Services"]}
SEND => {"api":"PbxTableUsers","mt":"ReplicateStart","src":"abc","add":false,"del":false,"columns":[{"cn":{}}]}
RECV <= {"mt":"AppInfo","app":"monitor"}
RECV <= {"mt":"ReplicateStartResult","src":"abc","api":"PbxTableUsers","columns":{}}
Can you please tell me what I'm doing wrong?
Picture of Matthias Schertler (innovaphone)
Moderator Registered 12 years 193 days
Matthias Schertler (innovaphone) Monday, 4 May 2020, 02:47 PM
Re: Replication using basic JSON messages
Hi,

it looks like the documentation is wrong.

The "columns" attribute of the "ReplicateStart" message is acutally an object, not an array. It should look like that:

{"mt":"ReplicateStartResult","api":"PbxTableUsers","columns":{"guid":{},"h323":{},"e164":{},"cn":{}}}

We will fix the documentation for the next SR.

BR
Matthias
Picture of Wim 4127
Registered 6 years 310 days
Wim 4127 Monday, 4 May 2020, 09:10 PM
Re: Replication using basic JSON messages
Ok, with the columns provided as objects I get a response that seems like a confirmation of my message, but, should I not start getting replication information? It now sends a Start result but I do not get any other info? I would expect getting all users? Or do I forget something. Additionally, how do I synchronize other tables that are also mentioned in the tutorial (but that use IReplicator and use C++, which is not possible here)? Please advise.

RECV <= {"mt":"AppChallenge"}
SEND => {"mt":"AppChallengeResult","challenge":"1234"}
RECV <= {"mt":"AppLogin","sip":"ExternalApp","guid":"e7125bb4e0aa5e01381300903340016f","dn":"ExternalApp","digest":"646022a5a5aed17ab3085671d5e4a7287726f75a143a08f362410ed5e7fbb7fd","domain":"xqting.be","app":"monitor","info":{"appobj":"ExternalApp","appurl":"http://10.0.0.101:8080/hub/monitor","cn":"ExternalApp","unlicensed":true,"groups":["monitored"],"apps":[]}}
SEND => {"mt":"AppLoginResult","ok":true}
RECV <= {"mt":"PbxInfo","domain":"xqting.be","pbx":"inno13-pbx","pbxDns":"inno13-pbx.xqting.be","apis":["EpSignal","PbxAdminApi","PbxApi","PbxMessages","PbxSignal","PbxTableUsers","RCC","Services"]}
SEND => {"api":"PbxTableUsers","mt":"ReplicateStart","src":"abc","add":true,"del":true,"columns":{"guid":{"update":true},"cn":{"update":true}}}
RECV <= {"mt":"AppInfo","app":"monitor"}
RECV <= {"mt":"ReplicateStartResult","src":"abc","api":"PbxTableUsers","columns":{"guid":{"update":true},"cn":{"update":true}}}
Picture of Matthias Schertler (innovaphone)
Moderator Registered 12 years 193 days
Matthias Schertler (innovaphone) Tuesday, 5 May 2020, 09:58 AM
Re: Replication using basic JSON messages
Hello Wim,

after the ReplicateStartResult you need to repeatedly send ReplicateNext to receive the next row until no more rows are returned.
  • {"api":"PbxTableUsers","mt":"ReplicateNext"}
  • {"mt":"ReplicateNextResult","api":"PbxTableUsers","columns":{"guid":"7b38f2d7bc7d5e01ee3d009033410fcc","h323":"endeavour","e164":"200","cn":"Endeavour"}}
  • {"api":"PbxTableUsers","mt":"ReplicateNext"}
  • ...
  • {"mt":"ReplicateNextResult","api":"PbxTableUsers"}
BR
Matthias
Picture of Wim 4127
Registered 6 years 310 days
Wim 4127 Tuesday, 5 May 2020, 01:10 PM
Re: Replication using basic JSON messages
Hi Matthias,

that does indeed get things working for the users table. Would be interesting to put also in the reference documentation I think.

In the tutorial http://sdk.innovaphone.com/doc/tutorials/Replicator.htm they also mention other tables that can be replicated. How do I set for which table I want to do the replication? I don't think changing the API name is the correct way? But I also do not see any other feeld in the reference documentation where I can set the table name.

Wim
Picture of Matthias Schertler (innovaphone)
Moderator Registered 12 years 193 days
Matthias Schertler (innovaphone) Tuesday, 5 May 2020, 01:54 PM
Re: Replication using basic JSON messages
Hi Wim,

those extra tables mentioned in the tutorial can be seen as multi-valued attributes, that can be requested the same way as other columns. But instead of a single value you get back an array.

Example:

  • {"mt":"ReplicateStart","api":"PbxTableUsers","columns":{"guid":{},"cn":{},"grps":{}}}
  • {"mt":"ReplicateNextResult","api":"PbxTableUsers","columns":{"guid":"26a83200deaf5e01a50b0090334106ee","cn":"Atlantis","grps":[{"name":"group1"},{"name":"group2","dyn":"in"}]}}
BR
Matthias
← You can define your color theme preference here