Telegram api setWebhook not working: Connection failed because the connected party did not respond properly

48 Views Asked by At

I have been using Ngrok and Azure intermittently as my hosting services. Until today, I did not encounter any problems. I last set my Ngrok URL as my webhook and worked on my Telegram bot. Today, when I initiated another Ngrok session and used its link to set my webhook, it gave me the following error:

('Connection aborted.', TimeoutError(10060, 'A connection attempt failed because the connected party did not properly respond after a period of time, or the established connection failed because the connected host has failed to respond', None, 10060, None))

My webhook is set to the ngrok url I set yesterday. I tried deleting it but it threw the error above again

I have searched for similar issues on the internet, but none of them seem to be related to my problem because Ngrok takes care of the certificates automatically. I have also tried setting up the webhook to my Azure URL, but it's not working for that as well. It's throwing the same error

This is the full error:

Traceback (most recent call last):
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 791, in urlopen
    response = self._make_request(
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 492, in _make_request
    raise new_e
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 468, in _make_request
    self._validate_conn(conn)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 1097, in _validate_conn
    conn.connect()
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 642, in connect
    sock_and_verified = _ssl_wrap_socket_and_match_hostname(
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 783, in _ssl_wrap_socket_and_match_hostname
    ssl_sock = ssl_wrap_socket(
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\ssl_.py", line 471, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\ssl_.py", line 515, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 486, in send
    resp = conn.urlopen(
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 845, in urlopen
    retries = retries.increment(
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\retry.py", line 470, in increment
    raise reraise(type(error), error, _stacktrace)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\util.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 791, in urlopen
    response = self._make_request(
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 492, in _make_request
    raise new_e
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 468, in _make_request
    self._validate_conn(conn)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 1097, in _validate_conn
    conn.connect()
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 642, in connect
    sock_and_verified = _ssl_wrap_socket_and_match_hostname(
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 783, in _ssl_wrap_socket_and_match_hostname
    ssl_sock = ssl_wrap_socket(
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\ssl_.py", line 471, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\ssl_.py", line 515, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', TimeoutError(10060, 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond', None, 10060, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "e:\Work\E-commerce-Telegram\WEBHOOKS.PY", line 14, in <module>
    response = requests.get(f'https://api.telegram.org/bot{BOT_TOKEN}/deleteWebhook?url={webhook_URL}')
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 501, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', TimeoutError(10060, 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond', None, 10060, None))

This same ngrok url works perfectly with my fb bot.

0

There are 0 best solutions below