App service - problems with logging to file and connection via PbxApi
Hello,
I am developing a Javascript-based app using the (at this moment) latest beta version of 13r3 and I have faced two issues in the service-part of the app (written in Javascript):
To be more concrete, here's the corresponding code snippet:
Simply sending a message from client to service and from service to client (without an API request in-between) works though.
Any idea what the cause of the aforementioned problems may be? Thanks!
Best regards
Marko
I am developing a Javascript-based app using the (at this moment) latest beta version of 13r3 and I have faced two issues in the service-part of the app (written in Javascript):
- the global
log(...)
function does not write the log into the file. When I open the log file using the AP Manager, I can see a lot of log messages from the SDK, but not my own. I have already tried changing the log-settings in AP Manager > MyApp > Diagnostics, but that didn't work- it seems that the service cannot access the PbxAdminApi, despite having the required permissions for it (as set in the advanced admin settings under PBX > Objects > MyApp > Apps > Grant Access to APIs).
new JsonApi("admin").onconnected(function(conn) {
log("Admin connected") // ----- this log doesn't work
if (conn.app == "mycompany-myapp") {
conn.onmessage(function(msg) {
var obj = JSON.parse(msg);
if (obj.mt == "Foo") {
var licensesApi = new PbxApi("PbxAdminApi");
licensesApi.onconnected(function(apiConn) {
// ----- this is never triggered
-----
apiConn.send(JSON.stringify({api: "PbxAdminApi", mt: "GetAppLics"}))
apiConn.onmessage(function(msg) {
let data = JSON.parse(msg)
conn.send(JSON.stringify({ api: "admin", mt: "FooResult", src: obj.src}))
})
}
})
}
});
The goal is the following: the client (not shown here) sends a message with mt : "Foo" to the service. The service receives the message and sends a PBX API request. Once the PBX API sends a response to the service, the service sends a response back to the client. In other words, I tried achieving what is described in this post, but it didn't work. The client never gets a response at the end. What happens in between is hard to tell, since logging doesn't work.Simply sending a message from client to service and from service to client (without an API request in-between) works though.
Any idea what the cause of the aforementioned problems may be? Thanks!
Best regards
Marko