I made a Discord Bot using Python 3.6. It runs and behaves perfectly when run on my computer, yet when I run it on PythonAnywhere, I get this message. I installed Discord.py and all necessary modules. Please help. I am not that very good with complex programming talk, and not at all good with web talk, so please answer as simply as you can. Does this issue only happen with PythonAnywhere or all remote hosting sites?
01:42 ~ $ python3.6 MyCoolBot.py
Traceback (most recent call last):
File "/home/CompuGenius/.local/lib/python3.6/site-packages/aiohttp/connector.py", line 601, in _create_direc
t_connection
local_addr=self._local_addr)
File "/usr/lib/python3.6/asyncio/base_events.py", line 778, in create_connection
raise exceptions[0]
File "/usr/lib/python3.6/asyncio/base_events.py", line 765, in create_connection
yield from self.sock_connect(sock, address)
File "/usr/lib/python3.6/asyncio/selector_events.py", line 450, in sock_connect
return (yield from fut)
File "/usr/lib/python3.6/asyncio/selector_events.py", line 480, in _sock_connect_cb
raise OSError(err, 'Connect call failed %s' % (address,))
ConnectionRefusedError: [Errno 111] Connect call failed ('104.16.58.5', 443)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/CompuGenius/.local/lib/python3.6/site-packages/aiohttp/connector.py", line 304, in connect
yield from self._create_connection(req)
File "/home/CompuGenius/.local/lib/python3.6/site-packages/aiohttp/connector.py", line 578, in _create_conne
ction
transport, proto = yield from self._create_direct_connection(req)
File "/home/CompuGenius/.local/lib/python3.6/site-packages/aiohttp/connector.py", line 624, in _create_direc
t_connection
(req.host, req.port, exc.strerror)) from exc
aiohttp.errors.ClientOSError: [Errno 111] Can not connect to discordapp.com:443 [Connect call failed ('104.16.
58.5', 443)]
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "MyCoolBot.py", line 39, in <module>
client.run('MY_BOT_TOKEN')
File "/home/CompuGenius/.local/lib/python3.6/site-packages/discord/client.py", line 519, in run
self.loop.run_until_complete(self.start(*args, **kwargs))
File "/usr/lib/python3.6/asyncio/base_events.py", line 468, in run_until_complete
return future.result()
File "/home/CompuGenius/.local/lib/python3.6/site-packages/discord/client.py", line 490, in start
yield from self.login(*args, **kwargs)
File "/home/CompuGenius/.local/lib/python3.6/site-packages/discord/client.py", line 416, in login
yield from getattr(self, '_login_' + str(n))(*args, **kwargs)
File "/home/CompuGenius/.local/lib/python3.6/site-packages/discord/client.py", line 346, in _login_1
data = yield from self.http.static_login(token, bot=is_bot)
File "/home/CompuGenius/.local/lib/python3.6/site-packages/discord/http.py", line 258, in static_login
data = yield from self.request(Route('GET', '/users/#me'))
File "/home/CompuGenius/.local/lib/python3.6/site-packages/discord/http.py", line 137, in request
r = yield from self.session.request(method, url, **kwargs)
File "/home/CompuGenius/.local/lib/python3.6/site-packages/aiohttp/client.py", line 555, in __iter__
resp = yield from self._coro
File "/home/CompuGenius/.local/lib/python3.6/site-packages/aiohttp/client.py", line 198, in _request
conn = yield from self._connector.connect(req)
File "/home/CompuGenius/.local/lib/python3.6/site-packages/aiohttp/connector.py", line 314, in connect
.format(key, exc.strerror)) from exc
aiohttp.errors.ClientOSError: [Errno 111] Cannot connect to host discordapp.com:443 ssl:True [Can not connect to discordapp.com:443 [Connect call failed ('104.16.58.5', 443)]]
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f4b25d81be0>
This is because PythonAnywhere requires a proxy in such a way that the aiohttp websockets don't support. There's a thread on their forums about it here: https://www.pythonanywhere.com/forums/topic/7384/ (See #Patrick Haugh's comment above)
Related
I'am trying to send task from django local app too remote rabbitmq server (preprod through vpn) but when I'm trying to send it always same error occure. Two errors code are related [Errno -9] Address family for hostname not supported and [Errno 111] Connection refused. The port 5672 is open the user is not the default user and the broker url is amqp://dist:dist#amqp.nopow-link.com:5672.
If someone can help me to understand what I'm doing wrong.
From the client:
>>> task.hello_task.apply_async()
Traceback (most recent call last):
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/kombu/utils/functional.py", line 30, in __call__
return self.__value__
AttributeError: 'ChannelPromise' object has no attribute '__value__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/amqp/transport.py", line 173, in _connect
host, port, family, socket.SOCK_STREAM, SOL_TCP)
File "/usr/lib/python3.7/socket.py", line 748, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -9] Address family for hostname not supported
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/kombu/connection.py", line 447, in _reraise_as_library_errors
yield
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/kombu/connection.py", line 438, in _ensure_connection
callback, timeout=timeout
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/kombu/utils/functional.py", line 312, in retry_over_time
return fun(*args, **kwargs)
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/kombu/connection.py", line 878, in _connection_factory
self._connection = self._establish_connection()
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/kombu/connection.py", line 813, in _establish_connection
conn = self.transport.establish_connection()
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/kombu/transport/pyamqp.py", line 201, in establish_connection
conn.connect()
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/amqp/connection.py", line 323, in connect
self.transport.connect()
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/amqp/transport.py", line 113, in connect
self._connect(self.host, self.port, self.connect_timeout)
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/amqp/transport.py", line 184, in _connect
"failed to resolve broker hostname"))
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/amqp/transport.py", line 197, in _connect
self.sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/celery/app/task.py", line 579, in apply_async
**options
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/celery/app/base.py", line 788, in send_task
amqp.send_task_message(P, name, message, **options)
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/celery/app/amqp.py", line 519, in send_task_message
**properties
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/kombu/messaging.py", line 180, in publish
exchange_name, declare, timeout
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/kombu/connection.py", line 524, in _ensured
return fun(*args, **kwargs)
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/kombu/messaging.py", line 186, in _publish
channel = self.channel
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/kombu/messaging.py", line 209, in _get_channel
channel = self._channel = channel()
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/kombu/utils/functional.py", line 32, in __call__
value = self.__value__ = self.__contract__()
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/kombu/messaging.py", line 225, in <lambda>
channel = ChannelPromise(lambda: connection.default_channel)
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/kombu/connection.py", line 896, in default_channel
self._ensure_connection(**conn_opts)
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/kombu/connection.py", line 438, in _ensure_connection
callback, timeout=timeout
File "/usr/lib/python3.7/contextlib.py", line 130, in __exit__
self.gen.throw(type, value, traceback)
File "/home/callmarl/env/nopow_link/website/application/lib/python3.7/site-packages/kombu/connection.py", line 451, in _reraise_as_library_errors
raise ConnectionError(str(exc)) from exc
kombu.exceptions.OperationalError: [Errno 111] Connection refused
On the server:
user
Listing permissions for user "dist" ...
/ .* .* .*
port
tcp 0 0 0.0.0.0:5672 0.0.0.0:* LISTEN 115995/beam.smp
On server nothing append when listening with tcpdump on port 5672 and no logs are displayed too (log.file.level = debug)
Notice: If I'am sending the same task from the server it's working well.
[2022-05-04 13:24:12,678: INFO/MainProcess] Task core.task.hello_task[a34f9869-03b8-4f4b-8139-b56f90deb469] received
[2022-05-04 13:24:12,680: WARNING/ForkPoolWorker-1] You want me to say hello?
[2022-05-04 13:24:12,680: WARNING/ForkPoolWorker-1] Hello.
[2022-05-04 13:24:12,680: INFO/ForkPoolWorker-1] Task core.task.hello_task[a34f9869-03b8-4f4b-8139-b56f90deb469] succeeded in 0.0006248119752854109s: None
I made a Discord Bot using Python 3.6. It runs and behaves perfectly when run on my computer, yet when I run it on PythonAnywhere, I get this message. I installed Discord.py and all necessary modules. Please help. I am not that very good with complex programming talk, and not at all good with web talk, so please answer as simply as you can. Does this issue only happen with PythonAnywhere or all remote hosting sites?
01:42 ~ $ python3.6 MyCoolBot.py
Traceback (most recent call last):
File "/home/CompuGenius/.local/lib/python3.6/site-packages/aiohttp/connector.py", line 601, in _create_direc
t_connection
local_addr=self._local_addr)
File "/usr/lib/python3.6/asyncio/base_events.py", line 778, in create_connection
raise exceptions[0]
File "/usr/lib/python3.6/asyncio/base_events.py", line 765, in create_connection
yield from self.sock_connect(sock, address)
File "/usr/lib/python3.6/asyncio/selector_events.py", line 450, in sock_connect
return (yield from fut)
File "/usr/lib/python3.6/asyncio/selector_events.py", line 480, in _sock_connect_cb
raise OSError(err, 'Connect call failed %s' % (address,))
ConnectionRefusedError: [Errno 111] Connect call failed ('104.16.58.5', 443)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/CompuGenius/.local/lib/python3.6/site-packages/aiohttp/connector.py", line 304, in connect
yield from self._create_connection(req)
File "/home/CompuGenius/.local/lib/python3.6/site-packages/aiohttp/connector.py", line 578, in _create_conne
ction
transport, proto = yield from self._create_direct_connection(req)
File "/home/CompuGenius/.local/lib/python3.6/site-packages/aiohttp/connector.py", line 624, in _create_direc
t_connection
(req.host, req.port, exc.strerror)) from exc
aiohttp.errors.ClientOSError: [Errno 111] Can not connect to discordapp.com:443 [Connect call failed ('104.16.
58.5', 443)]
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "MyCoolBot.py", line 39, in <module>
client.run('MY_BOT_TOKEN')
File "/home/CompuGenius/.local/lib/python3.6/site-packages/discord/client.py", line 519, in run
self.loop.run_until_complete(self.start(*args, **kwargs))
File "/usr/lib/python3.6/asyncio/base_events.py", line 468, in run_until_complete
return future.result()
File "/home/CompuGenius/.local/lib/python3.6/site-packages/discord/client.py", line 490, in start
yield from self.login(*args, **kwargs)
File "/home/CompuGenius/.local/lib/python3.6/site-packages/discord/client.py", line 416, in login
yield from getattr(self, '_login_' + str(n))(*args, **kwargs)
File "/home/CompuGenius/.local/lib/python3.6/site-packages/discord/client.py", line 346, in _login_1
data = yield from self.http.static_login(token, bot=is_bot)
File "/home/CompuGenius/.local/lib/python3.6/site-packages/discord/http.py", line 258, in static_login
data = yield from self.request(Route('GET', '/users/#me'))
File "/home/CompuGenius/.local/lib/python3.6/site-packages/discord/http.py", line 137, in request
r = yield from self.session.request(method, url, **kwargs)
File "/home/CompuGenius/.local/lib/python3.6/site-packages/aiohttp/client.py", line 555, in __iter__
resp = yield from self._coro
File "/home/CompuGenius/.local/lib/python3.6/site-packages/aiohttp/client.py", line 198, in _request
conn = yield from self._connector.connect(req)
File "/home/CompuGenius/.local/lib/python3.6/site-packages/aiohttp/connector.py", line 314, in connect
.format(key, exc.strerror)) from exc
aiohttp.errors.ClientOSError: [Errno 111] Cannot connect to host discordapp.com:443 ssl:True [Can not connect to discordapp.com:443 [Connect call failed ('104.16.58.5', 443)]]
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f4b25d81be0>
This is because PythonAnywhere requires a proxy in such a way that the aiohttp websockets don't support. There's a thread on their forums about it here: https://www.pythonanywhere.com/forums/topic/7384/ (See #Patrick Haugh's comment above)
I am trying to run the remote manager example code from the multiprocessing documentation in pypy3 but I get an error connecting the client.
Traceback (most recent call last):
File "C:/temp/testpypy/mp_client.py", line 7, in <module>
m.connect()
File "C:\Python\pypy3-v6.0.0-win32\lib-python\3\multiprocessing\managers.py", line 455, in connect
conn = Client(self._address, authkey=self._authkey)
File "C:\Python\pypy3-v6.0.0-win32\lib-python\3\multiprocessing\connection.py", line 493, in Client
answer_challenge(c, authkey)
File "C:\Python\pypy3-v6.0.0-win32\lib-python\3\multiprocessing\connection.py", line 732, in answer_challenge
message = connection.recv_bytes(256) # reject large message
File "C:\Python\pypy3-v6.0.0-win32\lib-python\3\multiprocessing\connection.py", line 216, in recv_bytes
buf = self._recv_bytes(maxlength)
File "C:\Python\pypy3-v6.0.0-win32\lib-python\3\multiprocessing\connection.py", line 407, in _recv_bytes
buf = self._recv(4)
File "C:\Python\pypy3-v6.0.0-win32\lib-python\3\multiprocessing\connection.py", line 386, in _recv
buf.write(chunk)
TypeError: 'str' does not support the buffer interface
if I try to connect to it from a CPython interpreter (which is my ultimate goal) I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Python\3.5.4.2\WinPython\python-3.5.4.amd64\lib\multiprocessing\managers.py", line 455, in connect
conn = Client(self._address, authkey=self._authkey)
File "c:\Python\3.5.4.2\WinPython\python-3.5.4.amd64\lib\multiprocessing\connection.py", line 493, in Client
answer_challenge(c, authkey)
File "c:\Python\3.5.4.2\WinPython\python-3.5.4.amd64\lib\multiprocessing\connection.py", line 737, in answer_challenge
response = connection.recv_bytes(256) # reject large message
File "c:\Python\3.5.4.2\WinPython\python-3.5.4.amd64\lib\multiprocessing\connection.py", line 218, in recv_bytes
self._bad_message_length()
File "c:\Python\3.5.4.2\WinPython\python-3.5.4.amd64\lib\multiprocessing\connection.py", line 151, in _bad_message_length
raise OSError("bad message length")
OSError: bad message length
Turns out to be a bug in PyPy3.
Here is the fixed ticket:
https://bitbucket.org/pypy/pypy/issues/2841/remote-multprocessing-issue#comment-45861347
celery workers stops working.
How to catch this error?
Connection timeout can happen due to any other reason also.
amqp==2.1.4
billiard==3.5.0.2
celery==4.0.2
docopt==0.4.0
kombu==4.0.2
pkg-resources==0.0.0
simplejson==3.10.0
vine==1.1.3
[2017-06-27 05:56:28,862: ERROR/MainProcess] Control command error: error(104, 'Connection reset by peer')
Traceback (most recent call last):
File "/home/usher/virt/delivery/local/lib/python2.7/site-packages /celery/worker/pidbox.py", line 42, in on_message
self.node.handle_message(body, message)
File "/home/usher/virt/delivery/local/lib/python2.7/site-packages/kombu/pidbox.py", line 129, in handle_message
return self.dispatch(**body)
File "/home/usher/virt/delivery/local/lib/python2.7/site-packages/kombu/pidbox.py", line 112, in dispatch
ticket=ticket)
File "/home/usher/virt/delivery/local/lib/python2.7/site-packages/kombu/pidbox.py", line 135, in reply
serializer=self.mailbox.serializer)
File "/home/usher/virt/delivery/local/lib/python2.7/site-packages/kombu/pidbox.py", line 265, in _publish_reply
**opts
File "/home/usher/virt/delivery/local/lib/python2.7/site-packages/kombu/messaging.py", line 181, in publish
exchange_name, declare,
File "/home/usher/virt/delivery/local/lib/python2.7/site-packages/kombu/messaging.py", line 203, in _publish
mandatory=mandatory, immediate=immediate,
File "/home/usher/virt/delivery/local/lib/python2.7/site-packages/amqp/channel.py", line 1748, in _basic_publish
(0, exchange, routing_key, mandatory, immediate), msg
File "/home/usher/virt/delivery/local/lib/python2.7/site-packages/amqp/abstract_channel.py", line 64, in send_method
conn.frame_writer(1, self.channel_id, sig, args, content)
File "/home/usher/virt/delivery/local/lib/python2.7/site-packages/amqp/method_framing.py", line 174, in write_frame
write(view[:offset])
File "/home/usher/virt/delivery/local/lib/python2.7/site-packages/amqp/transport.py", line 263, in write
self._write(s)
File "/usr/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
error: [Errno 104] Connection reset by peer
I have a setup containing varnish nginx and 2 pyramid backends one of them running socket.io app. All the stack works correctly on my local development computer, but i can't get to work the websocket part on the production computer. The traceback of the error that trows the socketio app when a client socket.io tries to connect:
[2012-11-20 14:32:00] "GET /socket.io/1/websocket/790777701707 HTTP/1.1" 101 - -
Traceback (most recent call last):
File "/var/pyramid/maxserver/eggs/gevent-0.13.8-py2.7-linux-i686.egg/gevent/greenlet.py", line 390, in run
result = self._run(*self.args, **self.kwargs)
File "/var/pyramid/maxserver/eggs/gevent_socketio-0.3.5_rc2-py2.7.egg/socketio/transports.py", line 226, in send_into_ws
websocket.send(message)
File "/var/pyramid/maxserver/eggs/gevent_websocket-0.3.6-py2.7.egg/geventwebsocket/websocket.py", line 350, in send
return self.send_frame(message, self.OPCODE_TEXT)
File "/var/pyramid/maxserver/eggs/gevent_websocket-0.3.6-py2.7.egg/geventwebsocket/websocket.py", line 340, in send_frame
self._write(combined)
File "/var/pyramid/maxserver/eggs/gevent-0.13.8-py2.7-linux-i686.egg/gevent/socket.py", line 515, in sendall
data_sent += self.send(_get_memory(data, data_sent), flags, timeout=timeleft)
File "/var/pyramid/maxserver/eggs/gevent-0.13.8-py2.7-linux-i686.egg/gevent/socket.py", line 483, in send
return sock.send(data, flags)
error: [Errno 32] Broken pipe
<Greenlet at 0xa449c0c: send_into_ws> failed with error
Traceback (most recent call last):
File "/var/pyramid/maxserver/eggs/gevent-0.13.8-py2.7-linux-i686.egg/gevent/greenlet.py", line 390, in run
result = self._run(*self.args, **self.kwargs)
File "/var/pyramid/maxserver/eggs/gevent_socketio-0.3.5_rc2-py2.7.egg/socketio/transports.py", line 230, in read_from_ws
message = websocket.receive()
File "/var/pyramid/maxserver/eggs/gevent_websocket-0.3.6-py2.7.egg/geventwebsocket/websocket.py", line 296, in receive
result = self._receive()
File "/var/pyramid/maxserver/eggs/gevent_websocket-0.3.6-py2.7.egg/geventwebsocket/websocket.py", line 244, in _receive
frame = self.receive_frame()
File "/var/pyramid/maxserver/eggs/gevent_websocket-0.3.6-py2.7.egg/geventwebsocket/websocket.py", line 177, in receive_frame
data0 = read(2)
File "/var/pyramid/maxserver/eggs/gevent_websocket-0.3.6-py2.7.egg/geventwebsocket/python_fixes.py", line 22, in readinto
return self._sock.recv_into(b)
File "/var/pyramid/maxserver/eggs/gevent-0.13.8-py2.7-linux-i686.egg/gevent/socket.py", line 472, in recv_into
wait_read(sock.fileno(), timeout=self.timeout, event=self._read_event)
File "/var/pyramid/maxserver/eggs/gevent-0.13.8-py2.7-linux-i686.egg/gevent/socket.py", line 169, in wait_read
switch_result = get_hub().switch()
File "/var/pyramid/maxserver/eggs/gevent-0.13.8-py2.7-linux-i686.egg/gevent/hub.py", line 164, in switch
return greenlet.switch(self)
timeout: timed out
<Greenlet at 0xa46157c: read_from_ws> failed with timeout
I've checked all python packages versions and there are identical in both computers. Also upgraded production computer to libevent 1.4.14b to match local computer.
I don't know which way to go to debug this. Help appreciated!