Error in connecting to a proxy address for a Heroku add-on
See original GitHub issueHello,
I am looking to try to connect to a SQL database via a Heroku app, but the database restricts IP addresses, and due to the nature of Heroku’s reliance on an EC2 instance with changing IP addresses, I need to use a proxy. I looked through the comments on this issue in mysql, and I used the configuration in one of the last comments. I’m repeating it here, but it was originally posted by @pierrickchabi 2 years ago:
var mysql2 = require('mysql2');
var url = require("url");
var SocksConnection = require('socksjs');
var mysql_server_options = {
host: 'database.ho.st',
port: 3306
};
var socks_options = {
host: 'proxy.ho.st',
port: 1080,
user: 'proxy_username',
pass: 'proxy_password'
};
var socksConn = new SocksConnection(mysql_server_options, socks_options);
var mysql_options = {
database: 'db_name',
user: 'db_username',
password: 'secret',
stream: socksConn
}
var mysqlConn = mysql2.createConnection(mysql_options);
mysqlConn.query('SELECT 1+1 as test1;', function(err, rows, fields) {
if (err) throw err;
console.log('Result: ', rows);
socksConn.dispose();
mysqlConn.end();
});
However, the error I get is:
TypeError: this.stream.destroy is not a function
at Connection._handleTimeoutError (/app/node_mudules/mysql2/lib/connection.js:164:17)
at tryOnTimeout (timers.js:224:198:5)
at Timer.listOnTimeout (timers.js:198:5)
...
I am not sure what the issue is, but it seems as if the connection is timing out. Any thoughts or help you can provide?
Issue Analytics
- State:
- Created 7 years ago
- Comments:16 (7 by maintainers)
Top Results From Across the Web
Heroku Error Codes
A router received a connection refused error when attempting to open a socket to your web process. This is usually a symptom of...
Read more >Fixie - Heroku Dev Center
Fixie acts as a proxy for outbound traffic, tunneling your requests through a known IP address.
Read more >Fixie Socks | Heroku Dev Center
Fixie Socks acts as a SOCKS V5 proxy for outbound traffic, tunneling your requests through a known IP address. Each Fixie subscriber is...
Read more >How do I make my nginx proxy connect to a Heroku app ...
Issue. You want to have an Nginx proxy connect to a Heroku app behind Heroku SSL but it keeps reporting errors like error:14094438:SSL...
Read more >QuotaGuard Static IP's | Heroku Dev Center
The Inbound Proxy allows you to always access your Heroku app on a Static IP address. This feature is available on our Micro...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Okay, I’ve finally fixed the connection. There was something going on with the socket callback, but I am all set now. Thanks for all the help in troubleshooting and the suggestion of a new socks client!
Can’t see any mention of destroy here https://nodejs.org/api/stream.html - probably we should remove it