2

I'm trying to eventually connect this project to an amazon ec2 redis server, but I can't seem to get sockets to work. According to here all I need to have is card on my account and I can use sockets on the google app servers.

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)

This is the error I'm getting in my app log.

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

Am I doing something wrong? Should I just wait for "billing" to be checked off on my app before I'm allowed access? Thanks for any help or advice you could give.

whuff739
  • 147
  • 1
  • 2
  • 10

1 Answers1

4

did you read the limitations in the docs for the socket support ?

In addition to billing needing to be enabled, it explicitly states

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

Port 80 at www.google.com isn't in this whitelist.

Tim Hoffman
  • 12,976
  • 1
  • 17
  • 29