{"action":"created","issue":{"url":"https://api.github.com/repos/snower/TorMySQL/issues/32","repository_url":"https://api.github.com/repos/snower/TorMySQL","labels_url":"https://api.github.com/repos/snower/TorMySQL/issues/32/labels{/name}","comments_url":"https://api.github.com/repos/snower/TorMySQL/issues/32/comments","events_url":"https://api.github.com/repos/snower/TorMySQL/issues/32/events","html_url":"https://github.com/snower/TorMySQL/issues/32","id":310959100,"number":32,"title":"Error while trying to connect to a Google Cloud SQL instance using ssl.","user":{"login":"c11z","id":529957,"avatar_url":"https://avatars2.githubusercontent.com/u/529957?v=4","gravatar_id":"","url":"https://api.github.com/users/c11z","html_url":"https://github.com/c11z","followers_url":"https://api.github.com/users/c11z/followers","following_url":"https://api.github.com/users/c11z/following{/other_user}","gists_url":"https://api.github.com/users/c11z/gists{/gist_id}","starred_url":"https://api.github.com/users/c11z/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c11z/subscriptions","organizations_url":"https://api.github.com/users/c11z/orgs","repos_url":"https://api.github.com/users/c11z/repos","events_url":"https://api.github.com/users/c11z/events{/privacy}","received_events_url":"https://api.github.com/users/c11z/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-04-03T19:04:15Z","updated_at":"2018-04-26T17:36:05Z","closed_at":null,"author_association":"NONE","body":"We are hosting our MySQL instance in Google Cloud SQL and we use ssl. Our pool is configured like this:\r\n```\r\npool = tormysql.ConnectionPool(\r\n    max_connections = 20, #max open connections\r\n    idle_seconds = 7200, #conntion idle timeout time, 0 is not timeout\r\n    wait_connection_timeout = 3, #wait connection timeout\r\n    host = \"{GCP_SQL_IP}\",\r\n    user = \"user\",\r\n    passwd = \"pass\",\r\n    db = \"production\",\r\n    charset = \"utf8\",\r\n    ssl = {\r\n        \"ca\": \"/path/to/server-ca.pem\",\r\n        \"key\": \"/path/to/client-key.pem\",\r\n        \"cert\": \"/path/to/client-cert.pem\",\r\n        \"check_hostname\": False\r\n    }\r\n)\r\n```\r\nThe error out of tornado is:\r\n```\r\nTraceback (most recent call last):\r\n  File \"app.py\", line 34, in <module>\r\n    ioloop.run_sync(test)\r\n  File \"/home/cory/.local/share/virtualenvs/tortest-C-kyhIye/lib/python2.7/site-packages/tornado/ioloop.py\", line 582, in run_sync\r\n    return future_cell[0].result()\r\n  File \"/home/cory/.local/share/virtualenvs/tortest-C-kyhIye/lib/python2.7/site-packages/tornado/concurrent.py\", line 260, in result\r\n    raise_exc_info(self._exc_info)\r\n  File \"/home/cory/.local/share/virtualenvs/tortest-C-kyhIye/lib/python2.7/site-packages/tornado/gen.py\", line 1107, in run\r\n    yielded = self.gen.throw(*exc_info)\r\n  File \"app.py\", line 24, in test\r\n    tx = yield pool.begin()\r\n  File \"/home/cory/.local/share/virtualenvs/tortest-C-kyhIye/lib/python2.7/site-packages/tornado/gen.py\", line 1099, in run\r\n    value = future.result()\r\n  File \"/home/cory/.local/share/virtualenvs/tortest-C-kyhIye/lib/python2.7/site-packages/tornado/concurrent.py\", line 260, in result\r\n    raise_exc_info(self._exc_info)\r\n  File \"/home/cory/.local/share/virtualenvs/tortest-C-kyhIye/lib/python2.7/site-packages/tornado/gen.py\", line 1107, in run\r\n    yielded = self.gen.throw(*exc_info)\r\n  File \"/home/cory/.local/share/virtualenvs/tortest-C-kyhIye/lib/python2.7/site-packages/tormysql/helpers.py\", line 203, in begin\r\n    connection = yield self.Connection()\r\n  File \"/home/cory/.local/share/virtualenvs/tortest-C-kyhIye/lib/python2.7/site-packages/tornado/gen.py\", line 1099, in run\r\n    value = future.result()\r\n  File \"/home/cory/.local/share/virtualenvs/tortest-C-kyhIye/lib/python2.7/site-packages/tornado/concurrent.py\", line 260, in result\r\n    raise_exc_info(self._exc_info)\r\n  File \"<string>\", line 3, in raise_exc_info\r\npymysql.err.OperationalError: (2003, \"Can't connect to MySQL server on {GCP_SQL_IP}:3306 (OperationalError(2013, 'Lost connection to MySQL server during query'))\")\r\n```\r\nAnd the error in the SQL logs is:\r\n```\r\n{\r\n    severity:  \"ERROR\"  \r\n    textPayload:  \"2018-04-03T18:33:14.500739Z 166871 [Note] Aborted connection 166871 to db: 'production' user: 'cory' host: '67.188.16.74' (Got an error reading communication packets)\"  \r\n    timestamp:  \"2018-04-03T18:33:14.500917Z\"\r\n} \r\n```\r\n\r\n* I can make a successful query if don't use ssl\r\n* I can make a successful query if I use ssl and only pymysql without tormysql's connection pool, but configure it in the same way.\r\n* Originally discovered with tormysql==0.3.6 and tornado==4.5 but also confirmed for 0.3.7/5.0\r\n\r\nSo my guess is that there is a bug with how tormysql uses ssl when it creates a connection pool of pymysql connections."},"comment":{"url":"https://api.github.com/repos/snower/TorMySQL/issues/comments/384725672","html_url":"https://github.com/snower/TorMySQL/issues/32#issuecomment-384725672","issue_url":"https://api.github.com/repos/snower/TorMySQL/issues/32","id":384725672,"user":{"login":"c11z","id":529957,"avatar_url":"https://avatars2.githubusercontent.com/u/529957?v=4","gravatar_id":"","url":"https://api.github.com/users/c11z","html_url":"https://github.com/c11z","followers_url":"https://api.github.com/users/c11z/followers","following_url":"https://api.github.com/users/c11z/following{/other_user}","gists_url":"https://api.github.com/users/c11z/gists{/gist_id}","starred_url":"https://api.github.com/users/c11z/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c11z/subscriptions","organizations_url":"https://api.github.com/users/c11z/orgs","repos_url":"https://api.github.com/users/c11z/repos","events_url":"https://api.github.com/users/c11z/events{/privacy}","received_events_url":"https://api.github.com/users/c11z/received_events","type":"User","site_admin":false},"created_at":"2018-04-26T17:36:05Z","updated_at":"2018-04-26T17:36:05Z","author_association":"NONE","body":"Thank you so much for the quick turn around.\r\nCurrently we are still on Tornado 4.5. If you wanted to back patch this to 3.6.1 I would love it. But we have a plan to get to 5.0 soon so we'll get there eventually."}}
{"actor":{"display_login":"c11z"}}