Need advice on MySQLdb connection denied by TCP/IP block

68 views
Skip to first unread message

Jeremy Deats

unread,
Feb 12, 2017, 2:56:40 PM2/12/17
to Google App Engine
Greetings all,

First time to post to this forum. So I have a service implemented in Python-Flask which I am currently running in App Engine. I decided to add a short block of mysql code to connect and insert into a mysql database. In this case I know the mysql database and related user account are working as I have the database configured to accept outside request and the user account I have configured to not be bound to specific incoming IP address. This has been fully tested from multiple outside servers and the problem is definately inside App Engine.

The dump from inside Google Cloud log view shows the failure point. This is when the connection is attempted.

File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/third_party/MySQLdb-1.2.5/MySQLdb/connections.py", line 193, in __init__ super(Connection, self).__init__(*args, **kwargs2) OperationalError: (2004, "Can't create TCP/IP socket (-1)")


This led me to do some digging and found another user who had the same problem with no resolve. 

Responses from others on that thread indicate that indicate that there is a problem with using TCP/IP sockets and the MySQLdb library inside App Engine. So I'm hoping to get confirmation this is true and curious about best work around approaches. It seems odd the MySQL library would be officially supported in App Engine only to be blocked because TCP IP connections made from MySQLDB calls are not supported.

I am adding MySQL support by including it in my App.yaml using version 1.5.2 

At first I was thinking that hosted in App Engine Flask could only communicate with Google SQL (managed MySQL) but In the GCS documentation it states explicitly that MySQL databases hosted outside GCS are supported. Although it shouldn't make a difference, in this case the MySQL database I'm connecting to is hosted in a Compute Engine VM inside the same GCS account where the App Engine instance is running.

Thanks,
Jeremy

Adam (Cloud Platform Support)

unread,
Feb 12, 2017, 4:27:28 PM2/12/17
to Google App Engine
This does work from PHP and Go (and I believe Java also using the standard MySQL JDBC driver in production as opposed to the Google driver), so if the vendored MySQLdb driver on the Python runtime has some specific limitation it's not documented. I'll look into testing this. You didn't mention if billing is enabled on your app, which is required for sockets to work on App Engine standard, can you confirm?

In the event there is some issue with the library, one alternative is to use the flexible environment.
Reply all
Reply to author
Forward
0 new messages