Google App Engine 套接字权限被拒绝
我正在尝试把这个项目连接到亚马逊的EC2 Redis服务器,但我好像无法让套接字(sockets)正常工作。根据这里的说法,我只需要在我的账户上有一张信用卡,就可以在谷歌的应用服务器上使用套接字。
这是我的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
我是不是做错了什么?我是不是应该等到我的应用上“计费”选项被勾选后才能访问?
谢谢你们提供的任何帮助或建议。
1 个回答
4
你有没有看过文档里关于socket支持的限制呢?
除了需要开启计费功能,文档里还明确说明了
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号端口不在这个白名单里。