Event Handlers : HTTP server part, some doubts

176 views
Skip to first unread message

Minal Chotalal

unread,
Aug 4, 2022, 12:58:54 PM8/4/22
to meetecho-janus
Hi everyone, 

I am currently working on Event Handlers.  I wanted to check, with event handlers, if I ca find any statistics that might be useful for my QoS and QoE streaming moitoring system. 
I was reading the documentation provided by meetecho group on the website. 
I was looking at https://www.meetecho.com/blog/event-handlers-a-practical-example/ and I was trying to implement this but without using an database, I want it to appear on the terminal just like in this meetecho demo - https://youtu.be/bR3CoeXF-Mo?t=1965 . So I skipped the database part and went straight away to the HTTP server part. But, I do not understand how to install basic-auth and how to create  node event-dv.js ... 
The link https://www.npmjs.com/package/basic-auth is not very self explanatory aswell ... 

Can someone guide me a little bit ? 

I have also checked the other documentation (https://janus.conf.meetecho.com/docs/eventhandlers.html & some conversations here in the group) and nothing helped me... :c 

Thank you.

Kind Regards,

Minal Chotalal

Lorenzo Miniero

unread,
Aug 5, 2022, 4:30:45 AM8/5/22
to meetecho-janus
You don't need any auth with the HTTP event handlers, it's optional. I'd say keep it easy and just start a generic HTTP server without authentication first.

L.

Minal Chotalal

unread,
Aug 8, 2022, 5:36:33 PM8/8/22
to meetecho-janus
Hi L, 

Thanks for your help!

I am still having issues with event handlers. 

To give you some context :  
I went to file janus.jcfg and on "events" I changed broadcast to true & stats_period = 5.
On file janus.eventhandler.sampleevh.jcfg I changed enabled=true & backend to my localhost:8000(my url) and commented user and password as you recommended. 

I have http server  python -m SimpleHTTPServer 8000 running and janus running aswell  and I get the following errors when running a Stream on Janus : 
[FATAL] [events/janus_gelfevh.c:janus_gelfevh_init:375] GELF event handler not enabled/needed, giving up...
[WARN] Retransmitting event in 100 ms... 
[ERR] [events/janus_sampleevh.c:janus_sampleevh_handler:763] Couldn't relay event to the backend: Timeout was reached

On the other side, when starting a HTTP server on port 8000, the following error appears : 
127.0.0.1 - - [08/Aug/2022 22:25:13] code 501, message Unsupported method ('POST')
 127.0.0.1 - - [08/Aug/2022 22:25:13] "POST / HTTP/1.1" 501 -

Can you help me solving these errors please ? 

Thank you ! 

Kind Regards, 

Minal

Erwin Dee Junio Villejo

unread,
Aug 8, 2022, 11:29:16 PM8/8/22
to meetecho-janus
Your simple HTTP server is a static files server. It serves static files (scanned from your local file system) and only supports GET requests for those files.

A Janus HTTP event handler should support POST requests. Janus does not need to download files from the HTTP event handler;  Janus wants to upload JSON events to it.

Try creating an HTTP server that defines a POST /api/v1/events route, even if it just prints the received request payload to stdout. E.g., using Node.js express:

// server.mjs
import express, { json } from 'express'

const app = express()

app.post('/api/v1/events', json(), (req, res) => {
  console.log(req.body)
  res.status(200).end()
})

app.listen(8000)

Br, Erwin

Minal Chotalal

unread,
Aug 10, 2022, 11:40:14 AM8/10/22
to meetecho-janus
hi Erwin, 

Thank you so much for your help! 
Unfortunately I am not being successful with your suggestion... 
When I run server.mjs, this is what appears to me : 
Screenshot from 2022-08-10 16-38-25.png

Can you help me on this please? 
Thank you so much!

Kind Regards, 

Minal 

Lorenzo Miniero

unread,
Aug 10, 2022, 12:25:38 PM8/10/22
to meetecho-janus
I don't think you're really reading the suggestions people are giving you and studying them. Erwin clearly said GET has nothing to do with event handlers, and shared an example on how to receive POST requests: but then you tried to open that link with a browser, which obviously will send a GET and not a POST. Please do some more homework ;-)

L.

Mirko Brankovic

unread,
Aug 11, 2022, 7:11:01 AM8/11/22
to meetecho-janus
And use Postman, and not browser ;)

--
You received this message because you are subscribed to the Google Groups "meetecho-janus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to meetecho-janu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/meetecho-janus/ad87178b-04e4-43ef-9d45-04f277f9ee1dn%40googlegroups.com.

Kinsley Kajiva

unread,
Aug 20, 2022, 6:57:49 PM8/20/22
to meetecho-janus
Hi , i have been also looking at this recently so I am facing issues not sure whats wrong at this point I am failing to get events , yes I have set up an endpoint that janus.eventhandler.sampleevh.jcfg  can send which is "POST - http://localhost:2087/api/janus/events/new"  , janus.eventhandler.sampleevh.jcfg  config is 
"
max_retransmissions = 5
  retransmissions_backoff = 100
"
My target  plugin is sip plugin, yes I have enabled it to send events :
"
register_ttl = 3600
 #user_agent = "Cool WebRTC Gateway"
 events = true

"

I have restarted the server a lot but I still don't get events, here is Janus init messages when i restart it -

[........]
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] [WARN] Data Channels support not compiled
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] Event handler plugins folder: /opt/janus/lib/janus/events
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] Setting event handlers statistics period to 1 seconds
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] Loading event handler plugin 'libjanus_gelfevh.so'...
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] [WARN] GELF event handler disabled (Janus API)
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] [FATAL] [events/janus_gelfevh.c:janus_gelfevh_init:374] GELF event handler not enabled/needed, giving up...
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] Loading event handler plugin 'libjanus_mqttevh.so'...
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] [WARN] MQTT event handler disabled
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] About to destroy MQTT EVH context...
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] JANUS MQTTEventHandler plugin destroyed!
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] Loading event handler plugin 'libjanus_rabbitmqevh.so'...
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] [WARN] RabbitMQ event handler disabled
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] Loading event handler plugin 'libjanus_sampleevh.so'...
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] JANUS SampleEventHandler plugin initialized!
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] Loading event handler plugin 'libjanus_wsevh.so'...
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] Joining Janus requests handler thread
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] [WARN] WebSockets event handler disabled
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] Plugins folder: /opt/janus/lib/janus/plugins
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] Loading plugin 'libjanus_audiobridge.so'...
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] Sessions watchdog started
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] JANUS AudioBridge plugin initialized!
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] Loading plugin 'libjanus_echotest.so'...
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] JANUS EchoTest plugin initialized!
2022-08-20T22:50:25Z janus-gateway.janus-gateway[8121]: [Sat Aug 20 22:50:25 2022] Loading plugin 'libjanus_nosip.so'...
[......]

Lorenzo Miniero

unread,
Aug 21, 2022, 3:38:45 AM8/21/22
to meetecho-janus
Event handlers must be enabled in janus.jcfg too, see broadcast = true towards the end of the file.

L.

Kinsley Kajiva

unread,
Aug 21, 2022, 5:09:54 AM8/21/22
to meetecho-janus
image_2022-08-21_110835334.png
yes , thats what i have already set in janus.jcfg, so I am still not getting the events .

Kinsley Kajiva

unread,
Aug 21, 2022, 8:29:51 AM8/21/22
to meetecho-janus
On my part the  issue has been solved,so I have come to realise that there is a problem with the installation method I have used , in this use case i have been using snap d on ubuntu , so for some reason it has been failing but after natively installing Janus i have been getting events , so i am not sure if any one will benefit from this but yes try to install natively if you ever run into this problem. 

Minal Chotalal

unread,
Aug 21, 2022, 5:53:04 PM8/21/22
to meetecho-janus
Hi Mirko & L & Erwin, 

Thank you so much for your help! And I'm sorry for late reply. 
Indeed, I was not studying what you all suggested me. I apologize. And thank you for helping me! 
I was successfull on receiving  HTTP POST requests. But, I was not successful on receiving an response when sending an HTTP POST request through Postman.
I feel like there is a detail missing somewhere here and I am not understanding where... 
Can you help me, please? 
Here is a image showing my HTTP POST on Postman & the HTTP Server. The highlighted brackets is the response I got from sending my HTTP POST.
Screenshot_from_2022-08-21_22-46-47.png
Thank you ,
Minal 

Mirko Brankovic

unread,
Aug 22, 2022, 3:48:49 AM8/22/22
to meetecho-janus
Did you also enable events in janus.jcfg, the main config file?



--
Regards,
Mirko

Minal Chotalal

unread,
Aug 22, 2022, 6:44:08 AM8/22/22
to meetecho-janus
Hi Mirko, 

Yes! I did. 
Check the images below : Screenshot_from_2022-08-21_22-59-16.pngScreenshot_from_2022-08-21_22-56-27.pngunknown (1).png

Thank you , 

Kind Regards, 

Minal 

Minal Chotalal

unread,
Aug 28, 2022, 2:28:44 PM8/28/22
to meetecho-janus
Hi, 
Can someone help me? I am still having this issue and don't know how to solve it :c 

Thank you. 

Kind Regards, 

Minal

Reply all
Reply to author
Forward
0 new messages