Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It only connect with localhost #154

Open
frodoe7 opened this issue Mar 21, 2020 · 2 comments
Open

It only connect with localhost #154

frodoe7 opened this issue Mar 21, 2020 · 2 comments

Comments

@frodoe7
Copy link

frodoe7 commented Mar 21, 2020

here's my codes

in localhost and it works well

const ib = require('ib');

    let client = new ib({ clientId : 1 , host : 'localhost' , port : 7497 });
    client.connect();
    client.on('connected' , () => {
        console.log("success");
    }).on("error" , () => {
        console.log("error");
    });

here , it's hosted in DigitalOcean server

const ib = require('ib');

    let client = new ib({ clientId : 1 , host : 'my public ip' , port : 7497 });
    client.connect();
    client.on('connected' , () => {
        console.log("success");
    }).on("error" , () => {
        console.log("error");
    });

it does not work in this case , my TWS are configured to receive from external IPs, not only the localhost (I also added my DigitalOcean server public ip to my TWS trusted IPs)

DigitalOcean blocks all the ports by default (except 80) , I also opened 7497
but still the same issue

@frodoe7
Copy link
Author

frodoe7 commented Mar 21, 2020

@tredondo
Copy link
Contributor

tredondo commented Mar 22, 2020

This isn't really a question about this library; it's about connectivity. The library doesn't do anything different depending on where it's run. I've been running it for years both locally and on VPSes.

I also added my DigitalOcean server public ip to my TWS trusted IPs

If TWS runs on the DO server, you need to add your client's public IP to the TWS trusted IPs list, not your DO server's IP.

Anyway, that's an insecure setup. I wouldn't trust TWS's SSL. They make it optional to begin with, which is patently stupid.

A secure setup is to only allow TWS to accept connections from localhost, then setup port forwarding on your PC using ssh -nNT -L 7497:localhost:7497 <yourServerIp>. That way you don't need to open port 7497 on the server; only the SSH port (which you should change to a random number above 1024 for additional security).

Also, you probably want to run Gateway v972 (not later because IB fucked it up and it disconnects every day) on the server, and use IBC Alpha to keep it running indefinitely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants