Forums

Telepot script runs from console, but not from "always on tasks"

Hi, I also have an issue with a telepot script. When I start my bot from the console, it works fine, but when I start it from "Always on tasks", I get this error (followed by many follow-up errors).

Feb 21 10:15:17 Traceback (most recent call last): 
Feb 21 10:15:17   File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 174, in _new_conn 
Feb 21 10:15:17     conn = connection.create_connection( 
Feb 21 10:15:17   File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 72, in create_connection 
Feb 21 10:15:17     for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 
Feb 21 10:15:17   File "/usr/local/lib/python3.10/socket.py", line 955, in getaddrinfo 
Feb 21 10:15:17     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):     
Feb 21 10:15:17 socket.gaierror: [Errno -2] Name or service not known

It looks like a DNS glitch, have you been getting this behavior constantly or it only started to happen after a while? I see your task is stopped, if you decide to rerun it, could you let us know, so we would check our logs?

Thanks. Yesterday was the first time I have tried to run the script as an always-on task. It has never worked so far. I have re-started the task just now.

From your error log, it looks like you're trying to connect through a proxy. Are you sure that you have configured the proxy connection correctly?

You are right. I had this line in my code:

telepot.api.set_proxy('http://proxy.server:3128')

It is necessary if you run a telegram bot from a free PythonAnywhere account (see here). But I am using a paid account now. I removed this line and now it's working. So to sum up, it looks like the above line must be used with free accounts and must not be used with paid accounts.

Glad to hear that you made it work!