Skip to content

Anyone can block your bot when using webhooks #1189

@vasinkd

Description

@vasinkd

Steps to reproduce

  1. Start bot using webhook

  2. On the other machine use the following code:

import socket

def client(ip, port, message):
    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
        sock.connect((ip, port))
        sock.sendall(bytes(message, 'ascii'))
        response = str(sock.recv(1024), 'ascii')
        print("Received: {}".format(response))
client(BOT_IP, BOT_PORT, "hello")
  1. Try to call some commands as a bot client/press buttons

Expected behaviour

Bot should keep receiving calls from Telegram

Actual behaviour

Bot is stuck and won't answer until client from step 2 stops his "attack"

Configuration

Operating System:
Ubuntu 16.04

Version of Python, python-telegram-bot & dependencies:
python 3.6, python-telegram-bot 10.1.0

Logs

Nothing in logs but I managed to localize the problem:
get_request in socketserver.TCPServer got blocked.
Here an inheritance path: socketserver.TCPServer -> http.server.HTTPServer -> telegram.utils.WebhookServer

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