Telegram sends duplicate POST JSON requests to webhook
Asked Answered
C

3

6

I am trying to develop city bot for telegram, but meet a problem. After sending message to bot, Telegram sends 2two duplicate requests to a webhook URL. Webhook script works twice and sends twice responses to user. Script - hellobot.php from official telegram docs. Server vps hosting with self-signed SSL, with uploaded cert key to telegram.

From server logs:

149.154.167.209 - - [28/Jun/2016:13:48:00 +0300] "POST /apps/gate.php HTTP/1.0" 200 86 "-" "- 149.154.167.209 - - [28/Jun/2016:13:48:00 +0300] "POST /apps/gate.php HTTP/1.1" 200 86 "-" "- 149.154.167.209 - - [28/Jun/2016:13:48:00 +0300] "POST /apps/gate.php HTTP/1.0" 200 86 "-" "- 149.154.167.209 - - [28/Jun/2016:13:48:00 +0300] "POST /apps/gate.php HTTP/1.1" 200 86 "-" "-

How to fix this?

Caribou answered 28/6, 2016 at 11:17 Comment(1)
Did you find an answer to this problem?Churchless
M
0

Could you post some code;

If you are asking to getupdates and send response to user upon each result ; it may send the duplication because you did not set the offset right

offset (Description): Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. ...

#getupdates_offset

Micropyle answered 29/6, 2016 at 23:52 Comment(1)
I asked about webhook method, thx for response but it is useless for me.Caribou
A
0

when Telegram receive a message from your bot user, send the message to your webhook URL in JSON format.

if

  1. occurs an error in your response page,
  2. or take very long time to finish the response,

then Telegram send the message to your server again.

Aekerly answered 4/7, 2016 at 1:7 Comment(1)
If you check attentively attached server logs,my server response with 200 code in normal timings.Caribou
R
0

Your bot should store last update_id, Then compare by update_id

Rosenkranz answered 20/11, 2021 at 12:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.