Skip to content

Webhook problem: 403 Request forbidden #412

@evasyuk

Description

@evasyuk

Steps to reproduce

  1. Enable webhook like this:
    #added to show the full picture inside this function
    #certificate     = '/path/to/cert1.pem'
    #full_chain      = '/path/to/fullchain1.pem'
    #key                = '/path/to/privkey1.pem'

    updater = Updater(TOKEN)
    updater.start_webhook(listen='0.0.0.0',
                          port=8443,
                          url_path=TOKEN,
                          key=key,
                          cert=full_chain,
                          webhook_url='https://eugenick.xyz:8443/' + TOKEN)
    updater.bot.setWebhook(url='https://eugenick.xyz:8443/' + TOKEN)

    dp = updater.dispatcher

    # on different commands - answer in Telegram
    dp.add_handler(CommandHandler("start", start))
    dp.add_handler(CommandHandler("help", help))

    # on noncommand i.e message - echo the message on Telegram
    dp.add_handler(MessageHandler([Filters.text], echo1))

    # log all errors
    dp.add_error_handler(error)

    updater.idle()
  1. Making fake request via console:
curl --tlsv1 -v -k -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache"  -d '{
> "update_id":10000,
> "message":{
>   "date":1441645532,
>   "chat":{
>      "last_name":"Test Lastname",
>      "id":1111111,
>      "first_name":"Test",
>      "username":"Test"
>   },
>   "message_id":1365,
>   "from":{
>      "last_name":"Test Lastname",
>      "id":1111111,
>      "first_name":"Test",
>      "username":"Test"
>   },
>   "text":"/start"
> }
> }' "https://eugenick.xyz:8443/TOKEN"
  1. Got next response in console:

curl_resopnse

Expected behaviour

I am expecting to see 200 OK or something similar

Actual behaviour

I got 403 Request Forbidden

Configuration

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.1 LTS
Release: 16.04
Codename: xenial

Version of Python, python-telegram-bot & dependencies:
python-telegram-bot 5.0.0
urllib3 1.17
certifi 2016.08.31
future 0.15.2
Python 2.7.12 (default, Jul 1 2016, 15:12:24) [GCC 5.4.0 20160609]

Logs

2016-09-15 20:01:07,642 - JobQueue - DEBUG - Auto-starting JobQueue
2016-09-15 20:01:07,642 - JobQueue - DEBUG - JobQueue thread started 
2016-09-15 20:01:07,644 - telegram.ext.updater - DEBUG - dispatcher - started
2016-09-15 20:01:07,644 - telegram.ext.dispatcher - DEBUG - Dispatcher started
2016-09-15 20:01:07,645 - telegram.bot - DEBUG - Entering: setWebhook
2016-09-15 20:01:07,646 - telegram.ext.updater - DEBUG - updater - started
2016-09-15 20:01:07,646 - telegram.ext.updater - DEBUG - Updater thread started
2016-09-15 20:01:07,678 - telegram.bot - DEBUG - Entering: setWebhook
2016-09-15 20:01:07,705 - telegram.bot - DEBUG - True
2016-09-15 20:01:07,705 - telegram.bot - DEBUG - Exiting: setWebhook
2016-09-15 20:01:07,728 - telegram.bot - DEBUG - True
2016-09-15 20:01:07,729 - telegram.bot - DEBUG - Exiting: setWebhook
2016-09-15 20:01:07,729 - telegram.utils.webhookhandler - DEBUG - Webhook Server started.
2016-09-15 20:09:40,645 - telegram.utils.webhookhandler - DEBUG - 94.45.109.127 - - "GET /TOKEN HTTP/1.1" 200 -
2016-09-15 20:19:32,794 - telegram.utils.webhookhandler - DEBUG - Webhook triggered
2016-09-15 20:19:32,795 - telegram.utils.webhookhandler - DEBUG - 94.45.109.127 - - code 403, message Forbidden
2016-09-15 20:19:32,796 - telegram.utils.webhookhandler - DEBUG - 94.45.109.127 - - "POST /TOKEN HTTP/1.1" 403 -
2016-09-15 20:23:02,756 - telegram.utils.webhookhandler - DEBUG - Webhook triggered
2016-09-15 20:23:02,758 - telegram.utils.webhookhandler - DEBUG - 94.45.109.127 - - code 403, message Forbidden
2016-09-15 20:23:02,759 - telegram.utils.webhookhandler - DEBUG - 94.45.109.127 - - "POST /TOKEN HTTP/1.1" 403 -
2016-09-15 20:23:21,094 - telegram.utils.webhookhandler - DEBUG - Webhook triggered
2016-09-15 20:23:21,096 - telegram.utils.webhookhandler - DEBUG - 94.45.109.127 - - code 403, message Forbidden
2016-09-15 20:23:21,096 - telegram.utils.webhookhandler - DEBUG - 94.45.109.127 - - "POST /TOKEN HTTP/1.1" 403 -
2016-09-15 20:25:17,167 - telegram.utils.webhookhandler - DEBUG - Webhook triggered
2016-09-15 20:25:17,168 - telegram.utils.webhookhandler - DEBUG - 45.63.99.236.vultr.com - - code 403, message Forbidden
2016-09-15 20:25:17,170 - telegram.utils.webhookhandler - DEBUG - 45.63.99.236.vultr.com - - "POST /TOKEN HTTP/1.1" 403 -
2016-09-15 20:25:32,335 - telegram.utils.webhookhandler - DEBUG - Webhook triggered
2016-09-15 20:25:32,335 - telegram.utils.webhookhandler - DEBUG - 45.63.99.236.vultr.com - - code 403, message Forbidden
2016-09-15 20:25:32,336 - telegram.utils.webhookhandler - DEBUG - 45.63.99.236.vultr.com - - "POST /TOKEN HTTP/1.1" 403 -

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions