Picture of Tobias 6022
Registered 3 years 56 days
Tobias 6022 Monday, 14 February 2022, 02:39 PM
Websocket connection error
Hello everyone,

I would like to query the members of a group and their status (busy, present, etc.) via the PBX API 'PbxAdminApi'. However, I can't connect to the websocket. I created the app object according to the following documentation: https://sdk.innovaphone.com/doc/appwebsocket/AppWebsocket.htm

For testing I use an html document that I open with Google Chrome:


<html>

<script>

let webSocket = new WebSocket('wss://192.x.x.x/PBX0/APPS/websocket');

webSocket.Xonmessage= function(e) { console.log(e)}

webSocket.send("test")

</script>

</html>


Do you have any suggestions?


Thanks

Tobias

error.jpeg

Andreas Fink
Moderator Registered 13 years 52 days
Andreas Fink (innovaphone) Monday, 14 February 2022, 04:11 PM
Re: Websocket connection error
Hello Tobias,

there are few problems:

1) in your case the WebSocket is not yet established (is still in connecting state, as first error message explains).

2) you should use an extended implementation of the WebSocket connection provided by innovaphone - AppWebsocket, that handles authentication and other details for you:

sdk.innovaphone.com => SDK V13r2 => Reference => JavaScript library for Apps

https://sdk.innovaphone.com/13r2/web1/appwebsocket/appwebsocket.htm


Please take a look on the example:
sdk.innovaphone.com => SDK V13r2 => Tutorials => Use RCC Api from external Web Page
https://sdk.innovaphone.com/13r2/doc/tutorials/RCCfromExternalWebPage.htm


Best Regards
Andreas Fink
Picture of Melinda
Registered 3 years 52 days
Melinda Friday, 18 February 2022, 06:19 PM
Re: Websocket connection error
Hello Andreas,

Thank you for the answer.

We are trying to follow the tutorial, we have many questions.
Let me know if we should open different threads.

1.
"Put together the httpfiles.zip with your own code accoding to this documentation." https://sdk.innovaphone.com/13r2/doc/appgeneric.htm#overview-httpfiles

Could we just get a sample somewhere? that would really speed up the process
(Probably the VSudio could generate one but that's troublesome to set up)

2. "Deployment to your test setup"
https://sdk.innovaphone.com/13r2/doc/appgeneric.htm#overview-httpfiles

a)
"Make sure the develpoper mode is enabled in the settings of the AP manager."
Why do we need developer mode?
How should we deploy to production?

b)
"Upload the binary together with your httpfiles.zip."
Where/how should we upload it?

3. Shared secret / Websocket
a)
https://sdk.innovaphone.com/13r2/doc/tutorials/RCCfromExternalWebPage.htm
"Add the App object to the PBX" where can we found this view?

b)
Ultimately we still just want to connect to the Websocket the simplest way possible.
As far as I could work out we can get the web/appwebsocket/innovaphone.appwebsocket.Connection.js file and host it on a different webserver and connect to PBX from the browser.
The only thing which is missing is the shared secret. Could that be configured without actually uploading a whole application / or with an empty application only with the secret? Would this setup work?
The thing is that we have a whole automated CI pipeline and dockerized runtime environment with is already integrated to the daily development...

Thanks,
Andreas Fink
Moderator Registered 13 years 52 days
Andreas Fink (innovaphone) Friday, 18 February 2022, 06:47 PM
Re: Websocket connection error
Hello Melinda,

before I answer your questions let us clarify your use case.

As I understand you have some server/back-end application that should connect to the innovaphone PBX to use some specific API provided by the PBX?

What exactly is required to be implemented from the user/application point of view? Any specific scenario would be great.

Best Regards
Andreas Fink
Picture of Melinda
Registered 3 years 52 days
Melinda Friday, 18 February 2022, 09:33 PM
Re: Websocket connection error
Thank you for the quick answer Andreas.

Our goals are two-fold:

1. We have a specific use-case
We'd like to save (for reporting reasons) the historical statuses/status changes of the agents. By status I mean things like: in call, available, not available...
In the simplest form in a table like this:
user_id,status,timestamp
1,CALL,2022-02-18 10:11.36
1,AVAILABLE,2022-02-18 10:15.21
...

2. Future
We'd like to understand how the APIs work for future integrations.
We've looked at the soap-api, however we'd prefer a push-based integration pattern over the soap's poll based.
Meaning that we'd prefer to open the websocket and receive the events, over polling the the soap api every X sec.

And yes, so the browser as client (html+js) is just to get things going, the ultimate goal is a backend application in (nodejs or python) which would connect to PBX. Ideally directly to the websocket, alternatively via a PBX App, that might be a gateway replicating the events or something similar. However this is exactly the part where we are struggling.

thanks,
Andreas Fink
Moderator Registered 13 years 52 days
Andreas Fink (innovaphone) Saturday, 19 February 2022, 04:23 PM
Re: Websocket connection error
Under SDK / Reference (https://sdk.innovaphone.com/13r2/doc/reference.htm) you can find a chapter about "PBX APIs", where all APIs provided by the innovaphone PBX are listed.


In the same chapter you will find a link to the document with a general description of the underlying WebSocket implementation, especially authentication towards PBX, that is done on the application layer:

https://sdk.innovaphone.com/13r2/doc/appwebsocket/AppWebsocket.htm


Take a look on the "Message Flow" chapter of this document, where an example communication between an external application and the PBX is described.

With this information it should be possible to implement authentication on the application layer, using Node.js and a WebSocket library.

For more detailed reference of the authentication procedure, you can refer to the innovaphone.appwebsocket.Connection.js .


With successful authentication you should be able to use RCC API for call monitoring and PBXSignal API for presence states monitoring.

Best Regards
Andreas Fink
Picture of Melinda
Registered 3 years 52 days
Melinda Sunday, 20 February 2022, 08:49 AM
Re: Websocket connection error
Thank you for the answer, it was helpful.


https://sdk.innovaphone.com/13r2/doc/appwebsocket/AppWebsocket.htm says:

"This sample message flow shows an example of a websocket connection to an app object on the PBX.

The app object assumed to have following sample configuration:

  • Object Type: App
  • Name: pbxadminapi
  • Password: password
  • App URL: http://1.2.3.4/PBX0/APPS/websocket
  • Grant access to APIs: Admin"
Where / how can one configure such an app Object?

Thanks

Andreas Fink
Moderator Registered 13 years 52 days
Andreas Fink (innovaphone) Monday, 21 February 2022, 08:58 AM
Re: Websocket connection error
PBX Objects can be created under PBX/Objects in the advanced administration UI: http://wiki.innovaphone.com/index.php?title=Reference13r2:PBX/Objects

However, it is usually better to ask the local PBX administrator. Explaining the PBX administration stuff here in forum would be out of scope.

Best Regards
Andreas Fink
Picture of Melinda
Registered 3 years 52 days
Melinda Friday, 4 March 2022, 02:16 PM
Re: Websocket connection error
Thank you for the answer we got as far as being able to connect. However we are not able to receive any updates from the system and we are lost what else should be configured. We added the App to a group where all other users are members as well.

1)
What else do we need to configure to make RCC work? as in: https://sdk.innovaphone.com/13r2/doc/tutorials/RCCfromExternalWebPage.htm

2)
We read the: https://sdk.innovaphone.com/doc/appwebsocket/PbxSignal.htm and https://sdk.innovaphone.com/13r2/doc/appwebsocket/Signal.htm, but it's somewhat unclear how all that gets together.
We did the registration and a signal for presence_subscribe, but since we get no response we are not sure if this is the good way of using this api?

Thank you!

AppWebsocket(pbxadminapi) ws://xxxxxxxxx/PBX0/APPS/websocket
pbxadminapi: opened ws://xxxxxxxxx/PBX0/APPS/websocket
pbxadminapi: send: {"mt":"AppChallenge"}
pbxadminapi: recv: {"mt":"AppChallengeResult","challenge":"XXXXX"}
pbxadminapi: send: {"mt":"AppLogin","app":"pbxadminapi","domain":"XXXX","sip":"pbxadminapi","guid":"00000000000000000000000000000000","dn":"Admin","digest":"XXXXXX","pbxObj":"pbxadminapi"}
pbxadminapi: recv: {"mt":"AppLoginResult","ok":true}
pbxadminapi: send: {"mt":"Initialize","api":"RCC"}
pbxadminapi: recv: {"mt":"InitializeResult","api":"RCC"}
pbxadminapi: send: {"api":"PbxSignal","mt":"Register","src":"9999999999","hw":"pbxadminapi","flags":"NO_MEDIA_CALL"}
pbxadminapi: recv: {"mt":"RegisterResult","src":"9999999999","api":"PbxSignal","addr":"XXXX","turn":"XXXX","turnUsr":"turn","turnPwd":"XXXX","prefixIntl":"000","prefixNtl":"00","prefixSubs":"0","subscriber":"4004","area":"751","country":"49"}
pbxadminapi: send: {"api":"PbxSignal","mt":"Signaling","call":9999999,"sig":{"type":"presence_subscribe"}}
pbxadminapi: send: {"mt":"KeepAlive"}
pbxadminapi: send: {"mt":"KeepAlive"}

Attached an image with the configuration.
pbx_config.png

Andreas Fink
Moderator Registered 13 years 52 days
Andreas Fink (innovaphone) Monday, 14 March 2022, 05:15 PM
Re: Websocket connection error
Hello Melinda,

PbxSignal and Signal APIs are not what are you looking for, you need RCC API:

Reference / PBX APIs / RCC
https://sdk.innovaphone.com/13r2/doc/appwebsocket/RCC.htm

In the first step of "Initialize" you are using a group method to define which users are visible. In your case you have to set the group IQM to "active" on the pbxadminapi Object, in order it can "see" other group members.


Additionally, I miss a UserInitialize message for a specific user in your example.


Other parts are looking pretty good.

Best Regards
Andreas Fink
Picture of Melinda
Registered 3 years 52 days
Melinda Saturday, 26 March 2022, 10:33 PM
Re: Websocket connection error
Hello Andreas,

I just wanted to report back that we've managed to get our setup working.
Thanks for all the help, we ended up using the PbxAdminApi.GetObject in combination of the RCC.UserInfo so that we get all the information we need.

Thanks,
← You can define your color theme preference here