I’m trying to connect to Anvil via uplink from pythonanywhere.com and I’m getting this error:
Connecting to wss://anvil.works/uplink
Traceback (most recent call last):
File “/home/madmaxx/server.py”, line 11, in
anvil.server.connect(“XXXXXXXXXXXXXXXXXXXXXXXXXXX”)
File “/home/madmaxx/.local/lib/python3.8/site-packages/anvil/server.py”, line 259, in connect
_get_connection()
File “/home/madmaxx/.local/lib/python3.8/site-packages/anvil/server.py”, line 246, in _get_connection
raise e
File “/home/madmaxx/.local/lib/python3.8/site-packages/anvil/server.py”, line 243, in _get_connection
_connection.connect()
File “/home/madmaxx/.local/lib/python3.8/site-packages/ws4py/client/init.py”, line 217, in connect
self.sock.connect(self.bind_addr)
File “/usr/lib/python3.8/ssl.py”, line 1342, in connect
self._real_connect(addr, False)
File “/usr/lib/python3.8/ssl.py”, line 1329, in _real_connect
super().connect(addr)
ConnectionRefusedError: [Errno 111] Connection refused
Is there any restriction? When I try to copy&paste the same code to google colab, it works as expected.
Ok after some attempts I’ve been able to setup a virtualenv with anvil-uplink installed and I can confirm what @madmaxx.cz is saying.
I get the same error.
Pythonanywhere doesn’t allow ping nor traceroute but a good old
I seem to remember (but can’t find a definitive) that you cannot connect to external servers unless they use http on the free account.
I might be wrong, but it’s worth checking.
If you go here : https://help.pythonanywhere.com/pages/
and search for “Can I use an external MySQL service” on that page, the section the answer is in implies http connectivity only. This probably means uplink won’t work on a free account.
I wanted to try the scheduled script run that is available in the free version of pythonanywhere as I wanted to use it for my son’s football club info scrape (as there is no rss feed or such) and I don’t want to pay 40 bucks for that (even though anvil is a great tool indeed)…
Ok I leave the word for the “proxy-aware” stuff to Anvil Team.
But I want to stress that you have alternatives to Uplinking if you need to send some data from a script running in pythonanywhere to you Anvil’s App.
Uplink, if available, is obviously the easiest and preferred way.
But you could set up an HTTP API in your App and call it from your pythonanywhere’s code.
Worse, yet workable, you could set up an email processor in your App and send emails to it from pythonanywhere’s code.
It’s Anvil. You always have options.
Options that are fun to explore.
BR