Forums

connection time out

This script worked fine, but it suddenly doesn't work this morning. The contents of the error are as follows. Is it possible to check?

Traceback (most recent call last): File "/usr/lib/python3.6/urllib/request.py", line 1318, in do_open encode_chunked=req.has_header('Transfer-encoding')) File "/usr/lib/python3.6/http/client.py", line 1254, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/lib/python3.6/http/client.py", line 1300, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/lib/python3.6/http/client.py", line 1249, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/lib/python3.6/http/client.py", line 1036, in _send_output self.send(msg) File "/usr/lib/python3.6/http/client.py", line 974, in send self.connect() File "/usr/lib/python3.6/http/client.py", line 946, in connect (self.host,self.port), self.timeout, self.source_address) File "/usr/lib/python3.6/socket.py", line 724, in create_connection raise err File "/usr/lib/python3.6/socket.py", line 713, in create_connection sock.connect(sa) TimeoutError: [Errno 110] Connection timed out During handling of the above exception, another exception occurred:

    import urllib.request
    from urllib.parse import urlparse

    with urllib.request.urlopen('http://openapi.molit.go.kr:8081/OpenAPI_ToolInstallPackage/service/rest/RTMSOBJSvc/getRTMSDataSvcAptTrade?ServiceKey=zNxtEJ7mbW0rTQsioiKuO4k%2BgsHwS4owhi7fULI7XOcjqB%2FDWm0gactlYSBceX7aP3DgDi3acU07a%2F%2BYk9dCog%3D%3D&LAWD_CD=11680&DEAL_YMD=202105') as requrl:
        res_body = requrl.read().decode('utf-8')
    soup = BeautifulSoup(res_body, 'html.parser')

Does it happen only on PythonAnywhere? What if you try that on your local machine?

It works on my local machine. Please check what changes have been made to the server environment. Firewall .. etc..

url : openapi.molit.go.kr port : 8081

We have not made any changes, but it is possible that the site in question is limiting connections from our servers or that there is some sort of network filtering going on. My experiments suggest that that is what is going on. There is, unfortunately, nothing that we can do about it - particularly if the site is responding to behaviour from PythonAnywhere that they are interpreting as abusive.

Can I know my server IP? I'll request to open firewall to them (target service vendor)

And can you check my firewall policy?

from pythonanywhere my server

to http://openapi.molit.go.kr

port 8081

The following url is the service url I've been using and it works fine.

http://openapi.molit.go.kr:8081/OpenAPI_ToolInstallPackage/service/rest/RTMSOBJSvc/getRTMSDataSvcAptTrade?ServiceKey=zNxtEJ7mbW0rTQsioiKuO4k%2BgsHwS4owhi7fULI7XOcjqB%2FDWm0gactlYSBceX7aP3DgDi3acU07a%2F%2BYk9dCog%3D%3D&LAWD_CD=11680&DEAL_YMD=202105

We are not limiting your ability to connect to the site. We do not (except in very specific circumstances) interfere with outgoing connections from paid accounts. If you cannot connect to the site, it is not because of something that we're doing and so we cannot undo it.

I asked if there were any limitations from the service vendor, and they replied that there are no limitations because they are OPEN API If so, what is the problem? Can I do outbound network checks in pythonanywhere? If I change it to a different url (e.g. google.com) in the source code, it works fine. openapi.molit.go.kr only this url does not work.

It's not happening on our side.

enter image description here

I think the firewall is blocked, and the Python Anywhere side or target service side. Is any command like 'netstat'

not sure about this one- it's possible that service side is blocking typical cloud hosting ips