Python Forum
Python error on pythonanywhere
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python error on pythonanywhere
#1
Hello,

so I have this error on deployment, I don't know if it's due to the constraints of my deployment server (pythonanywhere) or if it's related to something else.
My code works locally, but when I put it in my distant server and run it, it fails with a ClientConnectionError "Cannot connect to host [api_host]:443 ssl:default [Connect call failed ('api_ip', 443)]" where api_host/api_ip of another distant host I'm trying to contact with my code.
The exception is thrown from .local/lib/python3.8/site-packages/aiohttp/connector.py in _wrap_create_connection, line 943.

Is this a limitation of pythonanywhere regarding concurrent network calls ? (it works without the concurrent version). Or a python version problem ? Or something else ?

Please help me figuring out what's wrong,

Thx
Reply
#2
is it free account or paid one? free accounts are only allowed to connect to white-listed sites
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
It is a free account indeed, but it is part of the white-listed site, and works in sync mode. But I just coded an async version, and now it fails.
Reply
#4
I suggest trying it with verify_ssl = False in you aiohttp request
Reply
#5
Thanks for the idea, but didn't work. Anyway it wouldn't have explained why it works locally and not on pythonanywhere, or why it works with the sync'ed version and not async'ed.
Reply
#6
OKay so it appears pythonanywhere only sets up the http request, through a proxy (that whitelists some hosts though the one I'm interested in is whitelisted), and the websocket API that is used by aiohttp is not properly configured, so I get a connect failed error. Is there any way around that ?
Reply
#7
(Sep-22-2020, 02:00 AM)lukee Wrote: it appears pythonanywhere only sets up the http request,
I am not sure this is true. On the plan comparing page they claim "Specific sites via HTTP(S) only"
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#8
It is true though, I've tried changing just one line from requests.get to session.get and in the later case it fails with a connect issue.
See here, here or here.

So is there a way to configure the proxy manually? How can they set this restriction anyway ?

In the end I need to be able to make multiple concurrent API calls, whatever the means.

Thx
Reply
#9
So any idea plz ?
Reply
#10
I'm stuck on this question, it's way past my knowledge, so if someone could help me I'd be grateful.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020