softwarespartan / IB4m

Interactive Brokers API for Matlab
GNU General Public License v2.0
62 stars 21 forks source link

Couldn't Connect to TWS #27

Closed trippingCub closed 6 years ago

trippingCub commented 6 years ago

I'm stuck at the very start, with Matlab R2017b showing this error:

-1 502 Couldn't connect to TWS. Confirm that "Enable ActiveX and Socket Clients" is enabled on the TWS "Configure->API" menu.

I did everything mentioned in quick start, my matlab commant statements are:

cd 'softwarespartan-IB4m-15bb4fd';
addpath(path,pwd);
addpath(path,fullfile(pwd,'docs'))
javaaddpath(fullfile(pwd,'Jar','TWS.jar'))

AccountSummaryExample

I have navigated to IBM4 folder. And I configured TWS as required.

image

Can you please point what I'm doing wrong here? Appreciate your support.

softwarespartan commented 6 years ago

Thanks for reaching out.

Can you share the command you’re using to connect ? This is the “session.eConnect” api call in the example you referenced.

My initial guess is that the port provided in your connect call doesn’t match the port listed in your TWS config screen.

Cheers -abel

Sent from my iPhone

On May 27, 2018, at 2:08 PM, trippingCub notifications@github.com wrote:

I'm stuck at the very start, with Matlab R2017b showing this error:

-1 502 Couldn't connect to TWS. Confirm that "Enable ActiveX and Socket Clients" is enabled on the TWS "Configure->API" menu.

I did everything mentioned in quick start, my matlab commant statements are:

cd 'softwarespartan-IB4m-15bb4fd'; addpath(path,pwd); addpath(path,fullfile(pwd,'docs')) javaaddpath(fullfile(pwd,'Jar','TWS.jar'))

AccountSummaryExample I have navigated to IBM4 folder. And I configured TWS as required.

Can you please point what I'm doing wrong here? Appreciate your support.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

trippingCub commented 6 years ago

Abel,

Thanks for your fast response. I found this is AccountSummaryExample file:

% establish connection with TWS
session.eClientSocket.eConnect('127.0.0.1',7496,0);

The port numbers are different. Which one should I change? The one in the code?

trippingCub commented 6 years ago

I changed the port number in the AccountSummaryExample file, it was a succes but then showed this error:

Error using AccountSummaryExample (line 56) Java exception occurred: org.apache.commons.collections.BufferUnderflowException: The buffer is already empty

at org.apache.commons.collections.buffer.BoundedFifoBuffer.get(BoundedFifoBuffer.java:260)

softwarespartan commented 6 years ago

It just means the queue is empty . Some times it can take longer for TWS to reply so pause for longer

-abel

On Sun, May 27, 2018 at 2:50 PM trippingCub notifications@github.com wrote:

I changed the port number in the AccountSummaryExample file, it was a succes but then showed this error:

Error using AccountSummaryExample (line 56) Java exception occurred: org.apache.commons.collections.BufferUnderflowException: The buffer is already empty

at org.apache.commons.collections.buffer.BoundedFifoBuffer.get(BoundedFifoBuffer.java:260)

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/softwarespartan/IB4m/issues/27#issuecomment-392354281, or mute the thread https://github.com/notifications/unsubscribe-auth/AEWq1Ka76cCxLzegfGyIaYoxnxKn64Omks5t2vVtgaJpZM4UPXxs .

trippingCub commented 6 years ago

Thank you, everything works as it should now!

softwarespartan commented 6 years ago

Great! — don’t hesitate to reach out if you need anything additional

Sent from my iPhone

On May 28, 2018, at 12:10 AM, trippingCub notifications@github.com wrote:

Thank you, everything works as it should now!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.