{"action":"created","issue":{"url":"https://api.github.com/repos/felixge/node-mysql/issues/1029","labels_url":"https://api.github.com/repos/felixge/node-mysql/issues/1029/labels{/name}","comments_url":"https://api.github.com/repos/felixge/node-mysql/issues/1029/comments","events_url":"https://api.github.com/repos/felixge/node-mysql/issues/1029/events","html_url":"https://github.com/felixge/node-mysql/issues/1029","id":62845846,"number":1029,"title":"Connection.end never calls callback when connected through an SSH tunnel","user":{"login":"jarwol","id":1578302,"avatar_url":"https://avatars.githubusercontent.com/u/1578302?v=3","gravatar_id":"","url":"https://api.github.com/users/jarwol","html_url":"https://github.com/jarwol","followers_url":"https://api.github.com/users/jarwol/followers","following_url":"https://api.github.com/users/jarwol/following{/other_user}","gists_url":"https://api.github.com/users/jarwol/gists{/gist_id}","starred_url":"https://api.github.com/users/jarwol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarwol/subscriptions","organizations_url":"https://api.github.com/users/jarwol/orgs","repos_url":"https://api.github.com/users/jarwol/repos","events_url":"https://api.github.com/users/jarwol/events{/privacy}","received_events_url":"https://api.github.com/users/jarwol/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/felixge/node-mysql/labels/needs%20investigation","name":"needs investigation","color":"4cdbff"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-03-19T01:47:39Z","updated_at":"2015-03-20T08:13:20Z","closed_at":null,"body":"I'm trying to use node-mysql to connect to an AWS RDS instance that's only reachable from EC2 instances within the same VPC.  My specific use case is allowing a CI tool such as Codeship to run DB migrations before deploying new builds.  Since the Codeship hosts don't have access to my DB instance, it will have to tunnel through one of my EC2 instances.  This works like a charm, and I can execute queries against the DB fine, but when I try to close the connection, the callback is never called.  Since I need to close the tunnel after the db connection is closed, the script hangs.  I'm able to repro this with the following code (ssh/db config changed).\r\n\r\n    var Tunnel = require('tunnel-ssh'),\r\n        mysql = require('mysql');\r\n\r\n    var Tunnel = new Tunnel({\r\n      remoteHost: \"dbHost\",\r\n      remotePort: 3306,\r\n      localPort: 33333,\r\n      sshConfig: {\r\n        host: \"sshHost\",\r\n        username: \"ec2-user\",\r\n        privateKey: require('fs').readFileSync(\"/path/to/private/key\")\r\n      }\r\n    });\r\n\r\n    Tunnel.connect(function(err) {\r\n      if (err) {\r\n        return console.log(err);\r\n      }\r\n      var conn = new mysql.createConnection({\r\n        host: '127.0.0.1',\r\n        port: 33333,\r\n        database: \"database\",\r\n        user: \"dbUser\",\r\n        password: \"dbPass\"\r\n      });\r\n\r\n      conn.end(function(err) {\r\n        console.log(\"END\");\r\n      });\r\n    });\r\n\r\nI was able to follow the stack into the Quit sequence, but couldn't find where the problem was happening.  Let me know if you need any more info, or if you think this is a problem on the tunnel-ssh side.\r\n\r\nThanks,\r\nJared"},"comment":{"url":"https://api.github.com/repos/felixge/node-mysql/issues/comments/83946626","html_url":"https://github.com/felixge/node-mysql/issues/1029#issuecomment-83946626","issue_url":"https://api.github.com/repos/felixge/node-mysql/issues/1029","id":83946626,"user":{"login":"agebrock","id":196263,"avatar_url":"https://avatars.githubusercontent.com/u/196263?v=3","gravatar_id":"","url":"https://api.github.com/users/agebrock","html_url":"https://github.com/agebrock","followers_url":"https://api.github.com/users/agebrock/followers","following_url":"https://api.github.com/users/agebrock/following{/other_user}","gists_url":"https://api.github.com/users/agebrock/gists{/gist_id}","starred_url":"https://api.github.com/users/agebrock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agebrock/subscriptions","organizations_url":"https://api.github.com/users/agebrock/orgs","repos_url":"https://api.github.com/users/agebrock/repos","events_url":"https://api.github.com/users/agebrock/events{/privacy}","received_events_url":"https://api.github.com/users/agebrock/received_events","type":"User","site_admin":false},"created_at":"2015-03-20T08:13:20Z","updated_at":"2015-03-20T08:13:20Z","body":"Hey guys thanks for reporting. I think i got the problem fixed in the next major version. \r\nYou may crosscheck https://github.com/Finanzchef24-GmbH/tunnel-ssh/blob/release/1.0.0/example/mysql.js\r\n\r\nThanks for reporting."}}