RocketChat / Rocket.Chat

The communications platform that puts data protection first.
https://rocket.chat/
Other
39.62k stars 10.15k forks source link

Integration will Retry Outgoing Webhook even if status is 200 #25562

Open dmonn opened 2 years ago

dmonn commented 2 years ago

Description:

When turning on Webhook retry, the Integration will send retry attempts even if the first response was 200 / empty.

CleanShot 2022-05-19 at 09 21 40@2x

I see that the logs have received an empty response. It is not logged which status code it has received.

CleanShot 2022-05-19 at 09 22 10@2x

However in my own app, the signal was received and processed correctly, returned with status 200.

CleanShot 2022-05-19 at 09 23 10@2x

Steps to reproduce:

  1. Create an outgoing webhook on new message
  2. Turn on Retry logic
  3. On the webhook recipient, process the request as follows (this example uses Django)
def new_message(request):
    TOKEN = "XYXYXY"
    body = request.body.decode('utf8')
    data = json.loads(body)
    if data['token'] != TOKEN:
        return HttpResponse(status=403)

    # do some stuff

    return HttpResponse(status=200)
  1. See that the "stuff" is being done, but request is still retried

Expected behavior:

There should be no further retries after receiving a non-error response.

Actual behavior:

Request is retried three times.

Server Setup Information:

Docker

CleanShot 2022-04-15 at 11 34 32@2x

Client Setup Information

Desktop App or Browser Version: Browser, Chrome 99

psy commented 1 year ago

We are having the same issue. The problem is that rocketchat is awaiting content (as mentioned in the logs), see https://github.com/RocketChat/Rocket.Chat/blob/3b35f8bee550d6936a73e601146af7fb0c5739b8/apps/meteor/app/integrations/server/lib/triggerHandler.js#L780-L784 and https://github.com/RocketChat/Rocket.Chat/blob/3b35f8bee550d6936a73e601146af7fb0c5739b8/apps/meteor/app/integrations/server/lib/triggerHandler.js#L845-L869. To my knowledge this is in contrast to all standards. Webhooks should not be required to return any content.

SamirSaidani commented 11 months ago

This problem drives me mad.

I had the same problem with integrating rasa bot with rocketchat, the rasa bot answers multiple times, depending on the number of retry count set on "Outgoing Webhook Integration" in the Advanced Settings.

image

The problem was earlier mentioned in the forum here: https://forums.rocket.chat/t/rasa-rocketchat-integration-comms-issue/13558/11 https://forums.rocket.chat/t/rocket-chat-rasa-integration-rocket-chat-giving-multiple-times-same-response/13903

Took me hours to understand that disabling retry failed calls solves this issue.

morehek commented 8 months ago

Sending status 200 with body "{}" seems to solve the problem.

psy commented 8 months ago

Any content will workaround the problem, but the fix is to have rocketchat accept empty bodies.