我试图最终将此项目连接到亚马逊 ec2 redis 服务器,但我似乎无法让套接字工作。根据here我所需要的只是我的帐户上有卡,并且我可以使用 Google 应用服务器上的套接字。
main.py:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('www.google.com', 80))
s.send('GET / HTTP/1.1\r\n\r\n')
website = s.recv(1000)
self.response.write(website)
这是我在应用程序日志中收到的错误。
File "/base/data/home/apps/s~optimum-spring-544/1.374990298217149603/main.py", line 3, in <module>
s.connect(('www.google.com', 80))
File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/socket.py", line 222, in meth
return getattr(self._sock,name)(*args)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/remote_socket/_remote_socket.py", line 751, in connect
address_hostname_hint=_hostname_hint)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/remote_socket/_remote_socket.py", line 610, in _CreateSocket
raise _SystemExceptionFromAppError(e)
error: [Errno 13] Permission denied
我做错了什么吗?我是否应该等待应用程序上的“计费”被勾选后才被允许访问? 感谢您提供的任何帮助或建议。
最佳答案
您是否阅读了套接字支持文档中的限制?
除了需要启用计费之外,它还明确指出
Private, broadcast, multicast, and Google IP ranges (except those whitelisted below), are blocked:
Google Public DNS: 8.8.8.8, 8.8.4.4, 2001:4860:4860::8888, 2001:4860:4860::8844 port 53
Gmail SMTPS: smtp.gmail.com port 465 and 587
Gmail POP3S: pop.gmail.com port 995
Gmail IMAPS: imap.gmail.com port 993
www.google.com 的端口 80 不在此白名单中。
关于python - Google App Engine 套接字权限被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22949312/