Webhook returning 500 from openvidu server docker container

Hi Team,

I have 2 docker containers running in a VM host:

  1. Openvidu Server Docker container - Logs when webhook call returns 500 from API running in second container

[INFO] 2020-08-03 19:20:35,901 [3j1bfb9pi-e4-t0] io.openvidu.server.kurento.core.KurentoParticipant - PARTICIPANT con_PcEZo7QnBf: Is now publishing video in room vgp-fnpb-kim
[INFO] 2020-08-03 19:20:35,902 [3j1bfb9pi-e4-t0] io.openvidu.server.cdr.CDRLoggerFile - {“webrtcConnectionCreated”:{“sessionId”:“vgp-fnpb-kim”,“timestamp”:1596482435579,“streamId”:“str_CAM_Z0NW_con_PcEZo7QnBf”,“participantId”:“con_PcEZo7QnBf”,“connection”:“OUTBOUND”,“videoSource”:“CAMERA”,“videoFramerate”:-1,“videoDimensions”:"{“width”:640,“height”:480}",“audioEnabled”:true,“videoEnabled”:true}}
[ERROR] 2020-08-03 19:20:35,913 [3j1bfb9pi-e4-t0] io.openvidu.server.webhook.HttpWebhookSender - Unexpected HTTP status from callback endpoint https://vm-akj.southeastasia.cloudapp.azure.com/server/cdr: expected 200, received 500
[ERROR] 2020-08-03 19:20:35,913 [3j1bfb9pi-e4-t0] io.openvidu.server.webhook.HttpWebhookSender - IOException posting event [webrtcConnectionCreated] to endpoint https://vm-akj.southeastasia.cloudapp.azure.com/server/cdr: Unexpected HTTP status 500
[ERROR] 2020-08-03 19:20:35,914 [3j1bfb9pi-e4-t0] io.openvidu.server.webhook.CDRLoggerWebhook - Error sending webhook event: IOException posting event [webrtcConnectionCreated] to endpoint https://vm-akj.southeastasia.cloudapp.azure.com/server/cdr: Unexpected HTTP status 500

Refer “curl from openvidu server to webhook API.jpg” image that webhook API is accessible from openvidu server docker container

Configuration of Open vidu server in .env file that is read during openvidu server startup refer

OPENVIDU_WEBHOOK=true

OPENVIDU_WEBHOOK_ENDPOINT=https://vm-akj.southeastasia.cloudapp.azure.com/server/cdr

OPENVIDU_WEBHOOK_HEADERS=[]
OPENVIDU_WEBHOOK_HEADERS=[‘Content-Type: application/json’] --> also does not work

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

OPENVIDU_CDR=true

  1. Another Docker container (openvidu-app) which contains angular frontend and Nodejs backend code which hosts the webhook API.
    i.e https://vm-akj.southeastasia.cloudapp.azure.com/server/cdr - DNS of the VM wher both docker containers are running. This API requires Content-type header, which I have tried putting in OPENVIDU_WEBHOOK_HEADERS=[‘Content-Type: application/json’]. With or without this both times I receive 500.

The message is telling you what’s happening:

Unexpected HTTP status from callback endpoint https://vm-akj.southeastasia.cloudapp.azure.com/server/cdr : expected 200, received 500

And WebHook documentation states that your endpoint should return 200 as response:

https://docs.openvidu.io/en/2.15.0/reference-docs/openvidu-server-webhook/#how-your-webhook-endpoint-should-be

Your endpoint is returning a 500 error status. You should look into it.

Hi pablo,

The api is working it gives 200 as http status code and a response string data saved sucessfully is return when i do a curl from inside the docker container that runs the openvidu server, attached image in my post. When its called from openvidu server it gets 500, whereas my api is up and running. The same request i am getting 500 is working ad curl or postman and from wherever i try outside or inside the container.

Again, I don’t know why you are getting different responses from different HTTP Clients, but my point is really simple. This is the lines triggering the error you see in OpenVidu Server log:

The “response” object is the one returned by your side, by your webhook endpoint. And the status it brings is 500, not 200. So there must be something triggering an unexpected error in your endpoint’s code when processing OpenVidu event. Take a look at the logs of your endpoint when receving the openvidu-server event. I’m sure it must show some kind of error, somewhere.

Maybe the request you are performing with postman or curl brings an object different to the one sent by openvidu-server, and the processing differs somehow. It works fine with your test requests, but it fails with the real event sent by openvidu. Again, take a look to your endpoint logs to see whats happening when processing openvidu-server event.

Hi Pablo,

I have checked this code from github that your have referred here. The code only checks for http response code. I am able to get 500 in curl or postman when I hit the webhook API without sending the Content-Type header into my webhook API, but as per below lines of code from openvidu server code this should not matter, whether its there or not below lines of code will eventually add if its not there. Will check the API logs, once and revert back.

this.customHeaders = new ArrayList<>();
boolean contentTypeHeaderAdded = false;
for (Header header : headers) {
this.customHeaders.add(header);
if (!contentTypeHeaderAdded && HttpHeaders.CONTENT_TYPE.equals(header.getName())
&& “application/json”.equals(header.getValue())) {
contentTypeHeaderAdded = true;
}
}
if (!contentTypeHeaderAdded) {
this.customHeaders.add(new BasicHeader(HttpHeaders.CONTENT_TYPE, “application/json”));
}

Hi Pablo,

Issue resolved, the json received in webhook was parsed incorrectly.
Thanks for your support !