ConnectionRefusedError: [Errno 111] Connection refused

Hi,

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

(anvil_uplink_test) 14:12 ~/anvil_uplink_test $ telnet 52.56.203.177

Shows:

Trying 52.56.203.177...
telnet: Unable to connect to remote host: Connection refused
(anvil_uplink_test) 14:13 ~/anvil_uplink_test $  

It really looks like AWS is refusing connection from PythonAnyWhere.

I think we stop here and leave word to Anvil Team.

Welcome to Anvil @madmaxx.cz!

Are you on a free account with PythonAnywhere?

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.

edit
First paragraph of this pretty much confirms it :
https://help.pythonanywhere.com/pages/SMTPForFreeUsers

I see .amazonaws.com is whitelisted in https://help.pythonanywhere.com/pages/SMTPForFreeUsers
And Anvil’s server resolves to ec2-52-56-203-177.eu-west-2.compute.amazonaws.com

So, is it possible that the problem is due to the fact that:

Free users are restricted to HTTP/HTTPS only

while anvil.server.connect uses websocks?

Yeah, that’s kinda what I was getting at.

1 Like

Thank you all for your replies. It’s sad.

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)…

Could you ealborate a little what you’re trying to accomplish?
May be an approach can be found, compatible with all the restrictions.

Hi,

I’m trying to scrape a site on regular basis which is not possible with anvil free service.

Could you please check their reply?

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