Webhook Double up

Discussions relating to the REST API of Jiwa 7.

Webhook Double up

Postby SBarnes » Fri Jan 29, 2021 10:49 am

I am getting an issue with a debtor.updated webhook that whilst working and posting instantly is being sent twice, is there any reason this would be happening, this is with Jiwa 7.2.0 SR6?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Webhook Double up

Postby Mike.Sheen » Fri Jan 29, 2021 3:09 pm

SBarnes wrote:I am getting an issue with a debtor.updated webhook that whilst working and posting instantly is being sent twice, is there any reason this would be happening, this is with Jiwa 7.2.0 SR6?


I have had this reported before - there is some sort of issue with the aync nature of sending webhooks and the retry mechanism that we need to review.

I think it's related to the retry timer picking up a message as unsent inbetween the time the message is added to the queue and the initial sending (POST). Increasing the WebhooksRetryInterval system setting may help.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Webhook Double up

Postby Mike.Sheen » Fri Jan 29, 2021 3:14 pm

What does the WebhookMessagesTimer constructor look like in your REST API plugin?

I can see in 7.2.1 it's no longer asynchronously sending unsent or failed messages.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Webhook Double up

Postby SBarnes » Fri Jan 29, 2021 3:22 pm

Ok thanks I'll try that by changing the setting on a related issue I am trying to do a webhook double hop for an inventory update which has service function like


Code: Select all
public ServiceStack.Web.IHttpResult Post(JiwaFinancials.Jiwa.JiwaServiceModel.Inventory.InventoryItem request)


but request is the correct InventoryIem but all the properties aren't being set however, in other words it not deserializing the body

Code: Select all
string reqbody = base.Request.GetRawBody();


will actually get me the data that I need to do the hop but it seems a bit cludgy, I tried looking at IRequiresRequestStream but that didn't work any ideas on how to make it deserialize the body, in web api there is an annotation to do it?

The webhook message timer constructor is

Code: Select all
 public WebhookMessagesTimer(int TimerInterval)
        {
            _timer = new System.Timers.Timer { AutoReset = false, Interval = TimerInterval };

            _timer.Elapsed += delegate
            {
                _timer.Stop();

                //                  List<System.Threading.Tasks.Task> tasks = new List<System.Threading.Tasks.Task>();                  

                // Process the message queue
                List<SY_WebhookMessage> messages = RESTAPIPlugin.WebhookMessages.OrderBy(x => x.ItemNo).ToList<SY_WebhookMessage>();
                foreach (SY_WebhookMessage message in messages)
                {
                    //                     System.Threading.Tasks.Task task = System.Threading.Tasks.Task.Factory.StartNew(() => { WebHookController.CallWebhook(message); } );
                    //                          tasks.Add(task);
                    WebHookController.CallWebhook(message);
                }

                //                  if (tasks.Count > 0)
                //                  {                        
                //                     System.Threading.Tasks.Task.WaitAll(tasks.ToArray());
                //                     tasks.Clear();
                //                  }

                _timer.Start(); // restart the timer
            };

            _timer.Start();
        }
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Webhook Double up

Postby SBarnes » Fri Jan 29, 2021 3:40 pm

Hi Mike

Increasing the retry interval fixes the double up issue.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Webhook Double up

Postby SBarnes » Mon Feb 15, 2021 10:44 am

Hi Mike,

Whilst we have resolved the double up on our development server, under Azure our client is claiming that a hook is being received 4 times at the other end, I have checked the message and response tables and don't believe that this is at the Jiwa api end given the query results.

To troubleshoot this I have done the following:

1. After backing up the message and response tables I have flushed them of data.
2. I have increased the retry interval to 20 seconds so there is no danger of overlaps in the retries
3. I have lowered the retries to 2 in the theory if they keep keep getting 4 messages the problem won't be at the Jiwa end and this will prove it.

Do you have any other trouble shooting ideas besides the above?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Webhook Double up

Postby SBarnes » Mon Feb 15, 2021 5:00 pm

Ok this is weird the following SQL is returning data, should it?

Code: Select all
SELECT        dbo.SY_WebhookSubscription.RecID, dbo.SY_WebhookSubscription.SY_WebhookSubscriber_RecID, dbo.SY_WebhookSubscription.EventName, dbo.SY_WebhookSubscription.URL,
                         dbo.SY_WebhookSubscriber.Name, dbo.SY_WebhookSubscriber.RecID AS SY_WebhookSubscriberRecID
FROM            dbo.SY_WebhookSubscription LEFT OUTER JOIN
                         dbo.SY_WebhookSubscriber ON dbo.SY_WebhookSubscription.SY_WebhookSubscriber_RecID = dbo.SY_WebhookSubscriber.RecID
WHERE        (dbo.SY_WebhookSubscriber.RecID IS NULL)
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to REST API

Who is online

Users browsing this forum: No registered users and 2 guests

cron