RSATom / janus-gateway-snap

Helper repo for build Janus WebRTC Server on build.snapcraft.io and launchpad.net
https://github.com/meetecho/janus-gateway
GNU General Public License v3.0
28 stars 9 forks source link

how to start? #10

Closed kylebakerio closed 3 years ago

kylebakerio commented 3 years ago

After sudo snap install janus-gateway and then adding to my $PATH /snap/bin

KAJO:~$ $PATH
bash: /home/ft/.yarn/bin:/home/ft/.config/yarn/global/node_modules/.bin:/home/ft/.nvm/versions/node/v8.9.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin:/home/ft/.yarn/bin: No such file or directory

I open a new terminal, and the only auto-complete available for janu is janus-gateway.janus-pp-rec

which janus-gateway.janus-pp-rec 
/snap/bin/janus-gateway.janus-pp-rec

Not sure what janus-pp-rec is (looks like recording utilities for Janus something?), but not sure what's going on.

Does this package install it as a daemon instead perhaps? What's the proper way to test the demos after installing this way?

kylebakerio commented 3 years ago

basically: Is it just running always in the background now? how can I run the demos? what port is it at?

sudo snap logs janus-gateway

2020-08-20T21:44:20Z janus-gateway.janus-gateway[22618]: [WARN] The 'janus.transport.pfunix' plugin could not be initialized
2020-08-20T21:44:20Z janus-gateway.janus-gateway[22618]: Loading transport plugin 'libjanus_websockets.so'...
2020-08-20T21:44:20Z janus-gateway.janus-gateway[22618]: [WARN] libwebsockets has been built without IPv6 support, will bind to IPv4 only
2020-08-20T21:44:20Z janus-gateway.janus-gateway[22618]: libwebsockets logging: 0
2020-08-20T21:44:20Z janus-gateway.janus-gateway[22618]: WebSockets server started (port 8188)...
2020-08-20T21:44:20Z janus-gateway.janus-gateway[22618]: [WARN] Secure WebSockets server disabled
2020-08-20T21:44:20Z janus-gateway.janus-gateway[22618]: [WARN] Admin WebSockets server disabled
2020-08-20T21:44:20Z janus-gateway.janus-gateway[22618]: [WARN] Secure Admin WebSockets server disabled
2020-08-20T21:44:20Z janus-gateway.janus-gateway[22618]: JANUS WebSockets transport plugin initialized!
2020-08-20T21:44:20Z janus-gateway.janus-gateway[22618]: WebSockets thread started

and htop shows that indeed, there is a process janus being run on that PID.

Makes it seem like it started up, but I expected to be able to run janus-gateway and edit settings in a config file and that doesn't seem to be the case (found config file, but can't tell if it corresponds correctly, seems to be pointing at wrong folders by default...?)... Just, enough direction to access demo pages would help.

seeing in htop that it is called with -o, looked that up, I see

Janus as a Daemon

..

systemd

This section shows how you can add Janus as a service to systemd.

[Unit] Description=Janus WebRTC Server After=network.target

[Service] Type=simple ExecStart=/opt/janus/bin/janus -o Restart=on-abnormal LimitNOFILE=65536

[Install] WantedBy=multi-user.target

-- https://janus.conf.meetecho.com/docs/service.html

Still unsure about how to access demos, will keep investigating

kylebakerio commented 3 years ago

Just going to keep commenting my process as I go through this. Not much of a sysadmin, so forgive my bumbling--maybe this will help someone else later is my thoughts.

found in /etc/systemd/system that there's a file called snap.janus-gateway.janus-gateway.service, so ran sudo systemctl status snap.janus-gateway.janus-gateway.service and got

● snap.janus-gateway.janus-gateway.service - Service for snap application janus-gateway.janus-gateway
   Loaded: loaded (/etc/systemd/system/snap.janus-gateway.janus-gateway.service; enabled; vendor preset: 
   Active: active (running) since Thu 2020-08-20 23:34:09 EDT; 3h 53min left
 Main PID: 715 (janus)
    Tasks: 27 (limit: 4915)
   CGroup: /system.slice/snap.janus-gateway.janus-gateway.service
           └─715 /snap/janus-gateway/759/opt/janus/bin/janus -o

Aug 20 23:34:11 T460-DE-KAJO janus-gateway.janus-gateway[715]: [WARN] The 'janus.transport.pfunix' plugin
Aug 20 23:34:11 T460-DE-KAJO janus-gateway.janus-gateway[715]: Loading transport plugin 'libjanus_websock
Aug 20 23:34:11 T460-DE-KAJO janus-gateway.janus-gateway[715]: [WARN] libwebsockets has been built withou
Aug 20 23:34:11 T460-DE-KAJO janus-gateway.janus-gateway[715]: libwebsockets logging: 0
Aug 20 23:34:11 T460-DE-KAJO janus-gateway.janus-gateway[715]: WebSockets server started (port 8188)...
Aug 20 23:34:11 T460-DE-KAJO janus-gateway.janus-gateway[715]: [WARN] Secure WebSockets server disabled
Aug 20 23:34:11 T460-DE-KAJO janus-gateway.janus-gateway[715]: [WARN] Admin WebSockets server disabled
Aug 20 23:34:11 T460-DE-KAJO janus-gateway.janus-gateway[715]: [WARN] Secure Admin WebSockets server disa
Aug 20 23:34:11 T460-DE-KAJO janus-gateway.janus-gateway[715]: JANUS WebSockets transport plugin initiali
Aug 20 23:34:11 T460-DE-KAJO janus-gateway.janus-gateway[715]: WebSockets thread started

Which shows it is running in the background... just, still don't know how to run a demo or how to access it.

I do see /usr/bin/snap run janus-gateway in that file as the exec command, so in theory I could do that, but I don't know if it isn't configured to be run that way...?

Sure enough, if I try that, I get

Janus commit: d1d044ce781272715ef621abe9f7ac2f658842e6
Compiled on:  Thu Aug 20 08:08:07 UTC 2020

Logger plugins folder: /opt/janus/lib/janus/loggers
[WARN]  Couldn't access logger plugins folder...
---------------------------------------------------
  Starting Meetecho Janus (WebRTC Server) v0.10.5
---------------------------------------------------

Checking command line arguments...
Debug/log level is 4
Debug/log timestamps are disabled
Debug/log colors are disabled
Adding 'vmnet' to the ICE ignore list...
Using 192.168.43.197 as local IP...
[WARN] Token based authentication disabled
Initializing recorder code
Initializing ICE stuff (Full mode, ICE-TCP candidates disabled, half-trickle, IPv6 support disabled)
TURN REST API backend: (disabled)
[WARN] Janus is deployed on a private address (192.168.43.197) but you didn't specify any STUN server! Expect trouble if this is supposed to work over the internet and not just in a LAN...
Crypto: OpenSSL >= 1.1.0
[WARN] The libsrtp installation does not support AES-GCM profiles
[WARN] No cert/key specified, autogenerating some...
Fingerprint of our certificate: C6:FD:C3:15:66:14:17:3E:D6:38:67:A9:14:D0:7F:42:2B:28:9F:A0:66:A7:E4:07:FD:3C:40:53:47:61:53:8F
[WARN] Event handlers support disabled
Plugins folder: /opt/janus/lib/janus/plugins
Loading plugin 'libjanus_audiobridge.so'...
Sessions watchdog started
Joining Janus requests handler thread
JANUS AudioBridge plugin initialized!
Loading plugin 'libjanus_echotest.so'...
JANUS EchoTest plugin initialized!
Loading plugin 'libjanus_nosip.so'...
JANUS NoSIP plugin initialized!
Loading plugin 'libjanus_recordplay.so'...
JANUS Record&Play plugin initialized!
Loading plugin 'libjanus_sip.so'...
JANUS SIP plugin initialized!
Loading plugin 'libjanus_streaming.so'...
[ERR] [plugins/janus_streaming.c:janus_streaming_create_fd:5511] [rtp-sample] Bind failed for audio (port 5002)... 98 (Address already in use)
[ERR] [plugins/janus_streaming.c:janus_streaming_create_rtp_source:5719] Can't bind to port 5002 for audio...
[ERR] [plugins/janus_streaming.c:janus_streaming_init:1933] Error creating 'rtp' mountpoint 'rtp-sample'...
JANUS Streaming plugin initialized!
Loading plugin 'libjanus_textroom.so'...
JANUS TextRoom plugin initialized!
Loading plugin 'libjanus_videocall.so'...
JANUS VideoCall plugin initialized!
Loading plugin 'libjanus_videoroom.so'...
JANUS VideoRoom plugin initialized!
Loading plugin 'libjanus_voicemail.so'...
JANUS VoiceMail plugin initialized!
Transport plugins folder: /opt/janus/lib/janus/transports
Loading transport plugin 'libjanus_http.so'...
HTTP transport timer started
[FATAL] [transports/janus_http.c:janus_http_init:743] Couldn't start webserver on port 8088...
[WARN] HTTPS webserver disabled
[WARN] Admin/monitor HTTP webserver disabled
[WARN] Admin/monitor HTTPS webserver disabled
[WARN] No HTTP/HTTPS server started, giving up...
[WARN] The 'janus.transport.http' plugin could not be initialized
Loading transport plugin 'libjanus_pfunix.so'...
[WARN] Unix Sockets server disabled (Janus API)
[WARN] Unix Sockets server disabled (Admin API)
[WARN] No Unix Sockets server started, giving up...
[WARN] The 'janus.transport.pfunix' plugin could not be initialized
Loading transport plugin 'libjanus_websockets.so'...
[WARN] libwebsockets has been built without IPv6 support, will bind to IPv4 only
libwebsockets logging: 0
[FATAL] [transports/janus_websockets.c:janus_websockets_init:605] Error creating vhost for WebSockets server...
[WARN] Secure WebSockets server disabled
[WARN] Admin WebSockets server disabled
[WARN] Secure Admin WebSockets server disabled
[WARN] No WebSockets server started, giving up...
[WARN] The 'janus.transport.websockets' plugin could not be initialized
[FATAL] [janus.c:main:5275] No Janus API transport is available... enable at least one and restart Janus
kylebakerio commented 3 years ago

running sudo lsof -i -P -n | grep LISTEN shows it seems to be listening to ports 8088 & 8188

janus      715        root   19u  IPv6  17357      0t0  TCP *:8088 (LISTEN)
janus      715        root   26u  IPv4  21592      0t0  TCP *:8188 (LISTEN)

Might just try downloading demo files locally directly separately and opening them up in a browser?

kylebakerio commented 3 years ago

cloned the repository down. I read before somewhere that firefox allows webrtc without the html file being served from a server, chrome does not. I open the local 'echotest.html' file. I click 'start' to start the test. I get an error in a modal.

Probably a network error, is the server down?: [object Object]

I look through files, find the 'server' var in echotest.js. I manually switch it out for localhost:8088 to match what I found as far as ports.

I get a request for camera and mic permissions! But while this seems like a step in the right direction, ultimately I still get an error in a modal.

WebRTC error... Starting video failed

console

Library initialized: true
janus.js:446:2
Using REST API to contact Janus: http://localhost:8088/janus
janus.js:469:4
Object { janus: "success", transaction: "Eorj5XVVkPZF", data: {…} }
janus.js:932:5
Created session: 1816513901409544
janus.js:943:6
Long poll...
janus.js:557:3
Object { janus: "success", session_id: 1816513901409544, transaction: "RVkQmiSn0rIs", data: {…} }
janus.js:1270:5
Created handle: 8624948201684951
janus.js:1277:5
Plugin attached! (janus.plugin.echotest, id=8624948201684951)
echotest.js:104:10
Sending message: 
Object { audio: true, video: true }
echotest.js:117:10
Sending message to plugin (handle=8624948201684951):
janus.js:1388:3
Object { janus: "message", body: {…}, transaction: "iOI9PlF5EUtC" }
janus.js:1389:3
Trying a createOffer too (audio/video sendrecv)
echotest.js:119:10
isTrickleEnabled: undefined
janus.js:3603:3
isAudioSendEnabled: 
Object { data: true, update: false, keepAudio: false, keepVideo: false }
janus.js:3510:3
Consent dialog should be on now
echotest.js:152:10
isAudioSendEnabled: 
Object { data: true, update: false, keepAudio: false, keepVideo: false }
janus.js:3510:3
isVideoSendEnabled: 
Object { data: true, update: false, keepAudio: false, keepVideo: false }
janus.js:3543:3
isScreenSendEnabled: 
Object { data: true, update: false, keepAudio: false, keepVideo: false }
janus.js:3576:3
isAudioSendEnabled: 
Object { data: true, update: false, keepAudio: false, keepVideo: false }
janus.js:3510:3
isVideoSendEnabled: 
Object { data: true, update: false, keepAudio: false, keepVideo: false }
janus.js:3543:3
isAudioSendRequired: 
Object { data: true, update: false, keepAudio: false, keepVideo: false }
janus.js:3521:3
isVideoSendRequired: 
Object { data: true, update: false, keepAudio: false, keepVideo: false }
janus.js:3554:3
getUserMedia constraints 
Object { audio: false, video: true }
janus.js:2511:6
Long poll...
janus.js:557:3
Got a plugin event on session 1816513901409544
janus.js:767:4
Object { janus: "event", session_id: 1816513901409544, transaction: "iOI9PlF5EUtC", sender: 8624948201684951, plugindata: {…} }
janus.js:768:4
  -- Event is coming from 8624948201684951 (janus.plugin.echotest)
janus.js:779:4
Object { echotest: "event", result: "ok" }
janus.js:781:4
Notifying application...
janus.js:794:5
 ::: Got a message ::: 
Object { echotest: "event", result: "ok" }
echotest.js:185:10
Message sent!
janus.js:1431:5
Object { janus: "ack", session_id: 1816513901409544, transaction: "iOI9PlF5EUtC", hint: "I'm taking my time!" }
janus.js:1432:5
Consent dialog should be off now
echotest.js:152:10
WebRTC error: 
Object { code: undefined, name: "InternalError", message: "Starting video failed" }

I'm suspicious that this is due to not being server from a server, so will try that next. If that doesn't work, then perhaps it is from the server not being in the same directory as the install or something...?

kylebakerio commented 3 years ago

alright, that did it, have a locally running demo. I'll leave this here for now in case anyone else needs to go through this process in the future.

Just ran a python simpleHTTPserver in the 'html' folder cloned down from the meetecho/janus-gateway repo. then accessed demos at 0.0.0.0:8000 https://www.linuxjournal.com/content/tech-tip-really-simple-http-server-python

Also, manually changing ports previously was not needed--just happened to be that that one file referenced some other optional (?) ports (admin page needing 7088 or something I think?). the default ports on this snap of 8088 and 8089 are only ones needed for most demos it seems.

Looks like websockets don't work, though?

RSATom commented 3 years ago

It looks like it was very long day for you @kylebakerio :smile: Also it looks like I have to add some sort of "Getting started" to readme, and I will do it soon. Thank you for hint.

Right now I can say you finally do all right way. The only hint for you right now - all Janus config files reside in /var/snap/janus-gateway/common/etc, and on first install there placed default configs provided by Janus. So it's good idea look there right after install. What about websockets - according to https://github.com/meetecho/janus-gateway/blob/master/conf/janus.transport.websockets.jcfg.sample - it's enabled by default on 8188 port. And according to https://github.com/meetecho/janus-gateway/blob/master/conf/janus.transport.http.jcfg.sample - port 8088 is used by default for HTTP endpoint.

kylebakerio commented 3 years ago

I really appreciate this, btw--I spent the day before trying to get Janus running from the readme in the repo itself. I still can't get past an error where it says I have no transport enabled... Tried this method instead while waiting, and even without a readme it went smoother than the main repo. So thanks again for making this snap!

But yes, more info about how to use and configure this version would be very welcome. I'm not familiar with snap, new to Janus, and only a bumbling half-competent linux user, so a little direction goes a long way. For some reason, it seems very hard to find any guides related to Janus anywhere... I'm surprised, since Janus is such a large and well established project, it seems.

kylebakerio commented 3 years ago

Just to have a summary here more cleanly:

  1. sudo apt update

  2. sudo apt install snapd

  3. Do you need data channel support? Y: stable doesn't have it. See this discussion. If you can deal with daily restarts (e.g., just local testing), then sudo snap install janus-gateway --edge will have it. For prod environments, either switch it to dev mode to stop updates, or create your own snap. N: sudo snap install janus-gateway

  4. sudo systemctl status snap.janus-gateway.janus-gateway.service (verify it's running)

  5. sudo lsof -i -P -n | grep janus (check ports being listened to)

  6. sudo nano /var/snap/janus-gateway/common/etc to modify config values

  7. If you want to run a local demo, clone the original meetecho repo down to get the 'html' folder from there. Then run a simple local server to access the files on localhost. So:

    cd ~/where_you_keep_your_cloned_repos
    git clone https://github.com/meetecho/janus-gateway.git
    cd janus-gateway/html

    Then visit http://localhost:8000/echotest.html in your browser.

I'm going to go make a simple pull request with this to the readme. No pressure to accept it obviously, but since you want something, I figure it's better than nothing until you get around to it.

RSATom commented 3 years ago
  1. It's better use snap list janus-gateway and sudo snap logs janus-gateway (or sudo snap logs janus-gateway -f or sudo snap logs janus-gateway -n=all)
  2. It's better just look to configs in /var/snap/janus-gateway/common/etc
  3. There is no need to clone repo. Demos files already embedded to snap. So just
    cd /snap/janus-gateway/current/opt/janus/share/janus/demos && python -m SimpleHTTPServer 8080
kylebakerio commented 3 years ago

Updated pull request. Didn't fully understand your comment on 5, but assumed you meant to use cat instead of nano because I'm not sure how else to read that. (That's the same directory, so... huh?)

I added the logs commands you listed. The nice thing about keeping the one I mention is it makes it clear to the reader that this is a systemd daemon at a glance, so I'd recommend leaving it there (at the bottom at least), but that's up to you.

RSATom commented 3 years ago

Don't think guys who decide to use Janus will be so stupid to not be able understand how to view configs :smile: By 5. I just mean It's better view config files to get current configuration. Use sudo lsof -i -P -n | grep janus is a little bit tricky and hard to remember (at least to me).

RSATom commented 3 years ago

Anyway, it's merged. Thanks for contributing and help others who will decide to use it!

kylebakerio commented 3 years ago

Glad to help.

RSATom commented 3 years ago

I think we can close this issue then, right?