Webhook events are not dispatched after REST API calls

It seems that webhook events don’t arrive after REST API calls (session creation, session destruction etc).

The configuration is as follows:

GET https://…/openvidu/api/config

{
“VERSION”: “2.16.0”,

“OPENVIDU_CDR”: false,
“OPENVIDU_STREAMS_VIDEO_MAX_RECV_BANDWIDTH”: 1000,
“OPENVIDU_STREAMS_VIDEO_MIN_RECV_BANDWIDTH”: 300,
“OPENVIDU_STREAMS_VIDEO_MAX_SEND_BANDWIDTH”: 1000,
“OPENVIDU_STREAMS_VIDEO_MIN_SEND_BANDWIDTH”: 300,
“OPENVIDU_SESSIONS_GARBAGE_INTERVAL”: 900,
“OPENVIDU_SESSIONS_GARBAGE_THRESHOLD”: 3600,
“OPENVIDU_RECORDING”: false,
“OPENVIDU_WEBHOOK”: true,
“OPENVIDU_WEBHOOK_ENDPOINT”: “https://…/openvidu/webhook”,
“OPENVIDU_WEBHOOK_HEADERS”: [],
“OPENVIDU_WEBHOOK_EVENTS”: [
“sessionCreated”,
“sessionDestroyed”,
“participantJoined”,
“participantLeft”,
“webrtcConnectionCreated”,
“webrtcConnectionDestroyed”,
“recordingStatusChanged”,
“filterEventDispatched”,
“mediaNodeStatusChanged”
]
}

Logs:

openvidu-server_1  | [INFO] 2021-04-08 06:44:35,984 [http-nio-0.0.0.0-5443-exec-10] io.openvidu.server.rest.SessionRestController - REST API: POST /openvidu/api/sessions {}
openvidu-server_1  | [INFO] 2021-04-08 06:44:35,986 [http-nio-0.0.0.0-5443-exec-10] io.openvidu.server.rest.SessionRestController - New session ses_JBg99BTzl4 initialized [ses_JBg99BTzl4]
openvidu-server_1  | [INFO] 2021-04-08 06:45:27,654 [http-nio-0.0.0.0-5443-exec-4] io.openvidu.server.rest.SessionRestController - REST API: DELETE /openvidu/api/sessions/ses_JBg99BTzl4
openvidu-server_1  | [INFO] 2021-04-08 06:45:27,655 [http-nio-0.0.0.0-5443-exec-4] io.openvidu.server.core.SessionManager - Session 'ses_JBg99BTzl4' removed and closed

However, I see that the events are triggered from the RpcHandler:

openvidu-server_1 | [INFO] 2021-04-07 20:00:36,984 [jsonrpcTaskScheduler-1] io.openvidu.server.rpc.RpcHandler - Evicted participant with privateId l9vc6ktouteea16adec4m2mh34
openvidu-server_1 | [INFO] 2021-04-07 20:00:37,039 [pool-1-thread-1] io.openvidu.server.webhook.HttpWebhookSender - Event webrtcConnectionDestroyed successfully posted to uri https://…/openvidu/webhook
openvidu-server_1 | [INFO] 2021-04-07 20:00:37,118 [pool-1-thread-1] io.openvidu.server.webhook.HttpWebhookSender - Event participantLeft successfully posted to uri https://…/openvidu/webhook
openvidu-server_1 | [INFO] 2021-04-07 20:00:37,157 [pool-1-thread-1] io.openvidu.server.webhook.HttpWebhookSender - Event sessionDestroyed successfully posted to uri https://…/openvidu/webhook

Is that the intended behavior (there is nothing about that in the docs)?

How is your /opt/openvidu/.env configured? Can you show it without “secrets”?

Check that your webhook is reachable via curl or other http client from your server, but If OpenVIdu is showing this, requests are actually returning a success response.

The webhook works on direct access - I tested it.

Here is my .env

DOMAIN_OR_PUBLIC_IP=XXX.com

OPENVIDU_SECRET=XXX

CERTIFICATE_TYPE=selfsigned

LETSENCRYPT_EMAIL=user@example.com

OPENVIDU_RECORDING=false

OPENVIDU_RECORDING_DEBUG=false

OPENVIDU_RECORDING_PATH=/opt/openvidu/recordings

OPENVIDU_RECORDING_CUSTOM_LAYOUT=/opt/openvidu/custom-layout

OPENVIDU_RECORDING_PUBLIC_ACCESS=false

OPENVIDU_RECORDING_NOTIFICATION=publisher_moderator

OPENVIDU_RECORDING_AUTOSTOP_TIMEOUT=120

OPENVIDU_STREAMS_VIDEO_MAX_RECV_BANDWIDTH=1000

OPENVIDU_STREAMS_VIDEO_MIN_RECV_BANDWIDTH=300

OPENVIDU_STREAMS_VIDEO_MAX_SEND_BANDWIDTH=1000

OPENVIDU_STREAMS_VIDEO_MIN_SEND_BANDWIDTH=300

OPENVIDU_WEBHOOK=true

OPENVIDU_WEBHOOK_ENDPOINT=https://XXX/openvidu/webhook

OPENVIDU_WEBHOOK_EVENTS=[sessionCreated,sessionDestroyed,participantJoined,participantLeft,webrtcConnectionCreated,webrtcConnectionDestroyed,recordingStatusChanged,filterEventDispatched,mediaNodeStatusChanged]

OPENVIDU_SESSIONS_GARBAGE_INTERVAL=900

OPENVIDU_SESSIONS_GARBAGE_THRESHOLD=3600

OPENVIDU_CDR=false

OPENVIDU_CDR_PATH=/opt/openvidu/cdr

this is should be true too
OPENVIDU_CDR=true

No need. OPENVIDU_CDR should only be true if you want a written log of every action taking place in your OpenVidu deployment. NOthing to do with the Webhook (although the events registered in the CDR are the ones offered by the Webhook).

So any other suggestions or how I could debug this issue further?

I still don’t understand your problem. What are you saying, thatyou are not receiving the events in your webhook endpoint?

That’s not possible, as your OpenVidu Server logs is logging a successful post to your endpoint:

io.openvidu.server.webhook.HttpWebhookSender - Event webrtcConnectionDestroyed successfully posted to uri https://…/openvidu/webhoo

That message is only logged if OpenVidu Server Webhook service successfully performed the POST request and the endpoint https://…/openvidu/webhoo returned a 200 OK.

I am not receiving the webhooks after REST API calls to OpenVidu.

Webhooks work only after the events handled by the RpcHandler, but not after API calls.

For example, I do POST https://.../openvidu/api/sessions - the session is created successfully, the response is valid, but there is no sessionCreated event arriving via a webhook (and none in the logs in this case)

Because method POST https://.../openvidu/api/sessions won’t directly trigger the CDR/WebHook event sessionCreated. This event will be triggered whenever the session is actually placed in a media server, with its own resources properly assigned to it. THis only happens when the first user connects to it.

I will add this information in the event’s documentation.

1 Like