Webhook events not triggered


#1

Hi,

I have setup SG on AWS EC2 instance and have implemented webhooks to get the changed documents and fire the request which is pointed to the domain on our elastic beanstalk server. Even if I have added the event_handlers in the config file, I didn’t see any events coming on my server. Even the logs show nothing.

Below is my sync_gateway config file:
{
“interface”:":4984",
“adminInterface”:":4985",
“log”:[“REST+”,“CRUD+”,“EVENTS+”,“HTTP+”],
“databases”:{
“sync_gateway”:{
“server”:“http://XX.XXX.XXX.XX:8091”,
“bucket”:“igt”,
“users”: { “GUEST”: { “disabled”: true, “admin_channels”: [""] } },
“event_handlers”: {
“max_processes” : 1000,
“wait_for_process” : “20”,
“document_changed”: [
{
“handler”: “webhook”,
“url”: "https://dev.
**************.com/api/push/webhook",
“filter”: function(doc) { if (doc.type == "quickTask" || doc.type == "advTask") { return true; } return false; }
}]
},
“sync”:function(doc,oldDoc){ if (!doc.type) { throw ({forbidden: "A document must have a type"}); } if (oldDoc) { if (oldDoc.type != doc.type) { throw ({forbidden: "A document cannot change its type"}); } } channel(doc.channels) }
}
}
}

When I start the SG, I see all the logs on my screen except the EVENTS or EVENTS+ logs. Also I don’t see any post request made to the URL mentioned in the config. I have referred the issue discussion on https://github.com/couchbase/sync_gateway/issues/984. We are not using any docker on AWS, just the load balancer. Sync and other things work fine, but webhook events are not sent.

Thanks
Sumedh


#2

@sumedh908

Try changing your log line to:

"log":["REST+","CRUD+","Events","Events+","HTTP+"],

You should then see the Events logging, that will help to debug the underlying issue.

When starting Sync Gateway you should see log entries similar to the following:

2016-06-27T16:56:30.800+01:00 Events: Creating new JSEventFunction
2016-06-27T16:56:30.800+01:00 Events: Registered event handler: Webhook handler [https://dev.***************.com/api/push/webhook], for event type 0
2016-06-27T16:56:30.800+01:00 Events: Starting event manager with max processes:1000, wait time:20 ms

#3

Thanks for the input @andy . It worked. I see the events triggered and also the documents are now posted to my API.

Appreciate your help.