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

TURN REST API: Error parsing API from Janus #891

Open
ehfd opened this issue Dec 28, 2024 · 2 comments
Open

TURN REST API: Error parsing API from Janus #891

ehfd opened this issue Dec 28, 2024 · 2 comments

Comments

@ehfd
Copy link

ehfd commented Dec 28, 2024

CC @fancycode

Issue number one: The TURN REST API capability provided by the signaling server is not well documented, when one must use TURN with Janus.

r.HandleFunc("/turn/credentials", b.setComonHeaders(b.getTurnCredentials)).Methods("GET")

Documentation should specify correctly that they should add the turn_rest_api option in Janus pointing to /turn/credentials for janus.jcfg in order to utilze turn_rest_api_key:

nat: {
    stun_server = "stun.myurl.invalid"
    stun_port = 3478
    full_trickle = true
    turn_rest_api = "http://localhost:8080/turn/credentials"
    turn_rest_api_key = "<REDACTED>"
}

Issue number two:

Directly accessing http://localhost:8080/turn/credentials?service=turn&api=<REDACTED>&key=<REDACTED>&username=example (same format as https://github.com/meetecho/janus-gateway/blob/dc8323741043a75537fb770d42ca37498a3d8947/src/turnrest.c#L140) results correctly in:

{"username":"1700000000:example","password":"<REDACTED>","ttl":86400,"uris":["turn:turn.myurl.invalid:3478?transport=udp","turn:turn.myurl.invalid:3478?transport=tcp"]}

But in Janus:

[ERR] [turnrest.c:janus_turnrest_request:198] Couldn't parse response: error on line 1: '[' or '{' expected near end of file
[WARN] [{REDACTED}] Failed to add some remote candidates (added 0, expected 1)

Therefore, the TURN REST API is not usable, possibly an empty response for some reason?

@fancycode
Copy link
Member

If you increase the log level in Janus, you should see what was received:
https://github.com/meetecho/janus-gateway/blob/dc8323741043a75537fb770d42ca37498a3d8947/src/turnrest.c#L192-L194

@ehfd
Copy link
Author

ehfd commented Jan 17, 2025

[5060505176029085] Peer advertised 'actpass' DTLS role, we'll be a DTLS client
[5060505176029085] There are 1 audio, 1 video and 1 data m-lines
[5060505176029085] Setting ICE locally: got OFFER
[5060505176029085] Creating ICE agent (ICE Full mode, controlled)
Sending request: http://localhost:8080/turn/credentials?service=turn&api={REDACTED}&key={REDACTED}&username=2103426825996819
Got 0 bytes from the TURN REST API server

[ERR] [turnrest.c:janus_turnrest_request:198] Couldn't parse response: error on line 1: '[' or '{' expected near end of file[5060505176029085] Adding 10.244.42.121 to the addresses to gather candidates for
[5060505176029085] Parsing m-line #0...
[5060505176029085] ICE ufrag (local):   vq7x

I modified nothing from the request with curl and wget to get the response from http://localhost:8080/turn/credentials?service=turn&api={REDACTED}&key={REDACTED}&username=2103426825996819 and received the adequate response:

{"username":"1737200889:2103426825996819","password":"{REDACTED}","ttl":86400,"uris":["{REDACTED}"]}

Even tried 127.0.0.1 instead of localhost with no avail...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants