Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IB: Adapter activly refused

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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 Files
    Last edited by zweistein; 06-29-2009, 03:04 AM. Reason: better code

    #2
    >> 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.

    Comment


      #3
      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, 03:34 AM.

      Comment


        #4
        Thanks for your suggestion. We'll add it to the list of future considerations.

        Comment


          #5
          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

          Comment


            #6
            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
            Ray S.NinjaTrader Customer Service

            Comment


              #7
              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!
              Ray S.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by bmartz, 03-12-2024, 06:12 AM
              4 responses
              31 views
              0 likes
              Last Post bmartz
              by bmartz
               
              Started by Aviram Y, Today, 05:29 AM
              4 responses
              12 views
              0 likes
              Last Post Aviram Y  
              Started by algospoke, 04-17-2024, 06:40 PM
              3 responses
              28 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by gentlebenthebear, Today, 01:30 AM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by cls71, Today, 04:45 AM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X