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

error when trying to connect to the api #25

Open
eladnm opened this issue Aug 9, 2020 · 3 comments
Open

error when trying to connect to the api #25

eladnm opened this issue Aug 9, 2020 · 3 comments

Comments

@eladnm
Copy link

eladnm commented Aug 9, 2020

ERROR -1 502 Couldn't connect to TWS. Confirm that "Enable ActiveX and Socket EClients" 
is enabled and connection port is the same as "Socket Port" on the 
TWS "Edit->Global Configuration...->API->Settings" menu. Live Trading ports: 
TWS: 7496; IB Gateway: 4001. Simulated Trading ports for new installations 
of version 954.1 or newer:  TWS: 7497; IB Gateway: 4002
using this code:
from ibapi.client import EClient
from ibapi.wrapper import EWrapper  
class IBapi(EWrapper, EClient):
     def __init__(self):
         EClient.__init__(self, self) 

app = IBapi()
app.connect('127.0.0.1', 4002,123)
app.run()

tried all 4 ports with no luck...

@nshale2
Copy link

nshale2 commented Sep 3, 2021

@eladnm did you ever figure this out?

@Jake0303
Copy link

Jake0303 commented Sep 5, 2021

Having this issue too ....

@LaurenceBont
Copy link

Make sure you have "Enable ActiveX and Socket EClients" enabled in your settings. If you download and use VNCviewer you should be able to inspect the application and go to settings and see if both "Enable ActiveX and Socket EClients" are enabled.

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

4 participants