NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > Application Technical Support > Connecting

Connecting Support for establishing connections to your broker or market data service provider.

Reply
 
Thread Tools Display Modes
Old 06-29-2009, 02:40 AM   #1
zweistein
Senior Member
 
Join Date: Jan 2009
Posts: 584
Thanks: 2
Thanked 21 times in 12 posts
Default IB: Adapter activly refused

Hello to the Ninja Team and good morning,



I continue to have connection problems with IB in certain cases and I get the infamous message IB: No connection could be made because the target machine actively refused it.
There are numerous posts concerning this message!


I have traced down the problem and I quite firmly believe that this is a bug of the Ninja IB adapter.

Here my findings:

The content of the message makes sense: It means that TWS is already connected to Ninja and therefore a second connection is refused.

Can TWS already be connected to TWS? Yes it can and the typical case is that you have two or more IB accounts and one of them is already connected.
The IB adapter will then - erroneosly - take the running instance of TWS for good and will try to connect. But it will fail since the other IB connection is already there.

Here a fix proposal for your software guys:

Please check - when you get that message or always- wether there is another TWS connection already made in case you find the TWS application running. If you find another IB connection open then please load a new TWS instance instead and connect to the new TWS instance.

for example (pseudo-code)

ConnectToTWSAdapter(){

List<Connection> connections=FindAllActiveConnections();
List<TWSInstance> twsInstances = FindAllRunningIstances(TWS);
List<TWSInstance> twsAvailable=new List<TWSInstance>(twsInstances);
// create a copy to work on

foreach(Connection c in connections){

if c.Adapter==IB && c.IsConnected) {
twsavailable.Remove(c.twsInstance);
}

}

TWSInstance useMeTWS=null;
if(twsAvailable.Count>0) useMeTWS=twsAvailable[0];

if(useMeTWS==null) {
useMeTWS=LoadNewTWSInstance()
}

connectToInstance(useMeTWS);
}


I would welcome if your developers could revise the IB adapter logic and hopefully the above suggestions are useful and appreciated.

Best regards
Andreas
Attached Images
File Type: jpg Untitled.jpg (17.0 KB, 8 views)
Last edited by zweistein; 06-29-2009 at 03:04 AM. Reason: better code
zweistein is offline  
Reply With Quote
Old 06-29-2009, 02:58 AM   #2
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

>> The IB adapter will then - erroneosly - take the running instance of TWS for good and will try to connect.
This is not an error but works as expected: NT will try to connect to a running TWS instance.
NinjaTrader_Dierk is offline  
Reply With Quote
Old 06-29-2009, 03:31 AM   #3
zweistein
Senior Member
 
Join Date: Jan 2009
Posts: 584
Thanks: 2
Thanked 21 times in 12 posts
Default

Yes, but your approach is a bit simplistic:

You must differenciate the tws running instances between running tws instrances already connected and those not connected.
For a new connection you must use a running TWS instance not yet connected.


Otherwise your error will always show up when you try to connect automatically to a second IB . Current solution is to load the second TWS manually.
Remember that you offer MultiBroker licenses and I expect you to have your logic revised for this.

Best regards
Last edited by zweistein; 06-29-2009 at 03:34 AM.
zweistein is offline  
Reply With Quote
Old 06-29-2009, 03:34 AM   #4
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

Thanks for your suggestion. We'll add it to the list of future considerations.
NinjaTrader_Dierk is offline  
Reply With Quote
Old 06-29-2009, 11:44 AM   #5
shakeham
Junior Member
 
Join Date: Jun 2009
Posts: 1
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by NinjaTrader_Dierk View Post
>> The IB adapter will then - erroneosly - take the running instance of TWS for good and will try to connect.
This is not an error but works as expected: NT will try to connect to a running TWS instance.

Dear Admin, I also have the same problem of connecting to IB. actively refused by IB TWS. It keeps saying that every single time no matter I have TWS running or not. Does anyone actually has NinjaTrader working with latest TWS?
Thanks
shakeham is offline  
Reply With Quote
Old 06-29-2009, 11:55 AM   #6
NinjaTrader_RJ
NinjaTrader Customer Service
 
NinjaTrader_RJ's Avatar
 
Join Date: Jul 2008
Location: Denver, CO, USA
Posts: 1,828
Thanks: 4
Thanked 19 times in 18 posts
Default

Quote:
Originally Posted by shakeham View Post
Dear Admin, I also have the same problem of connecting to IB. actively refused by IB TWS. It keeps saying that every single time no matter I have TWS running or not. Does anyone actually has NinjaTrader working with latest TWS?
Thanks
Hello,

Thank you for your post.

The "latest TWS" is NOT supported by NinjaTrader 6.5. Please downgrade to TWS 892.7 from here: http://www.ninjatrader.com/webnew/su...ivebrokers.htm
NinjaTrader_RJ is offline  
Reply With Quote
Old 06-29-2009, 01:45 PM   #7
NinjaTrader_RJ
NinjaTrader Customer Service
 
NinjaTrader_RJ's Avatar
 
Join Date: Jul 2008
Location: Denver, CO, USA
Posts: 1,828
Thanks: 4
Thanked 19 times in 18 posts
Default

Quote:
Originally Posted by shakeham View Post
Dear Admin, I also have the same problem of connecting to IB. actively refused by IB TWS. It keeps saying that every single time no matter I have TWS running or not. Does anyone actually has NinjaTrader working with latest TWS?
Thanks
Please make sure you have followed each step in the connection guide from my last post as the error you received indicates some steps were missed.

Thank you!
NinjaTrader_RJ is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
FIX adapter nicko9 Connecting 9 01-19-2011 03:52 PM
Login Failed.IB. Adapter.MessageLoop Razorin Connecting 6 03-25-2009 02:50 PM
IB adapter bug - can not run live heech Connecting 12 03-25-2009 02:56 AM
Login failed - target machine actively refused it MarkSanDiego Installation and Licensing 3 11-26-2008 04:14 AM
IB Adapter optimisation queries Aussie2 General Programming 2 03-04-2008 03:40 PM


All times are GMT -6. The time now is 02:15 PM.