Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

listHandles only works on a session you created #18

Closed
sampierson opened this issue Nov 5, 2022 · 3 comments
Closed

listHandles only works on a session you created #18

sampierson opened this issue Nov 5, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@sampierson
Copy link

sampierson commented Nov 5, 2022

I'm building a tool to interrogate our Janus servers and build a graph of who is connected to whom.
Part of this process is to list all sessions then list their handles.

I can do this with direct http calls, but I cannot do it with janode. If I try to list handles for a session I did not create, Connection._handleMessage complains that: "session xxxxxxxxxxxx not found for incoming message success".
Here: https://github.com/meetecho/janode/blob/master/src/connection.js#L194

It seems that Connection keeps a cache of sessions so the right session can handle responses. But this is an admin function that takes a session parameter, and does not require one to establish a session first.

Here is some code to demonstrate the issue:

import Janode from 'janode';

const connection = await Janode.connect({
  is_admin: true,
  address: {
    url: "ws://127.0.0.1:7188/janus",
    apisecret: "janusoverlord"
  }
});

const r1 = await connection.listSessions();
console.log("Got sessions response", r1.sessions)
const r2 = await connection.listHandles(r1.sessions[0]);
console.log("Got handles response", handles);

connection.close();

I'm using a Janus with admin enabled on the websocket, and a videoroom call underway.

Here is the output:

2022-11-05T03:58:42.018Z - INFO : [janode.js] creating new connection
2022-11-05T03:58:42.021Z - INFO : [tmanager.js] [3340554914002515] creating new transaction manager (debug=false)
2022-11-05T03:58:42.021Z - INFO : [transport-ws.js] [3340554914002516] trying connection with ws://127.0.0.1:7188/janus
2022-11-05T03:58:42.032Z - INFO : [transport-ws.js] [3340554914002516] websocket connected
2022-11-05T03:58:42.032Z - INFO : [transport-ws.js] [3340554914002516] websocket ping task scheduled every 10 seconds
Got sessions response [ 5013312951136826, 353991153114233 ]
2022-11-05T03:58:42.035Z - INFO : [connection.js] [3340554914002516] requesting handle list
2022-11-05T03:58:42.036Z - WARN : [connection.js] [3340554914002516] session 5013312951136826 not found for incoming message success

I'm using janode version 1.6.4

@atoppi
Copy link
Member

atoppi commented Nov 7, 2022

Thanks for reporting this @sampierson!
Indeed janode keeps track of the existing sessions owned by a connection and heirs that abstraction from janus where sessions always live inside connections.
I guess for admin connections this does not make much sense, since you can query the status of the server without actually owning the sessions.
A possibile solution is to filter message handling for admin connections, I'll try to take a look in the next days.

Meanwhile you might want to check this new tool for janus that could accomplish the same task without janode.

@atoppi atoppi added the bug Something isn't working label Nov 7, 2022
@sampierson
Copy link
Author

Thanks for responding @atoppi.
I should have mentioned I have a workaround - I just send a list_handles directly to the Janus HTTP admin API.

@atoppi atoppi closed this as completed in be4e62e Nov 14, 2022
@atoppi
Copy link
Member

atoppi commented Nov 14, 2022

@sampierson this should be fixed now, thanks again for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants