Keyboard Shortcuts
ctrl + shift + ? :
Show all keyboard shortcuts
ctrl + g :
Navigate to a group
ctrl + shift + f :
Find
ctrl + / :
Quick actions
esc to dismiss
Likes
Search
API thinks it's "connected" before I granted the incoming connection request
Hi,
I'm playing around with the API and I have the following in my code (taken from
? although it's failing in exactly the same way that my own code was failing before it):?// Create a new EClientSocket object ??????????? client = new EClientSocket (this); ??????? // Connect to the TWS or IB Gateway application ??????? // Leave null for localhost ??????? // Port Number (should match TWS/IB Gateway configuration ??????? client.eConnect (null, 7496, 0); ??????? // Pause here for connection to complete ??????? try ??????? { ??????????? // Thread.sleep (1000); ??????????? while (! (client.isConnected())); ??????? } ??????? catch (Exception e) ??????? { ??????? } ??????? System.out.println("***CONNECTED***"); the last line - "CONNECTED" is being reached BEFORE I have responded to the "Accept incoming connection request" dialog box in TWS. So, in a nutshell, the code thinks it's "connected" even though I haven't granted the connection request in TWS. The program then continues to do stuff by fails with an EOFException because it's not actually connected. I don't understand why or how the API can think it's connected before I've granted the request. Can anybody help me with this? Thanks. Jason |
||||||||||||||||||||
Nick
I don't have an answer to your question but I have an alternative approach.
toggle quoted message
Show quoted text
You always get a NextValidId event after you successfully connect so some people will just do nothing until they get NextValidId and then assume they are connected and continue with starting up the program. On 1/4/2016 11:00 AM, jasonl534@... [TWSAPI] wrote:
I don't understand why or how the API can think it's connected before I've granted the request. |
||||||||||||||||||||
Jason, I guess this happens due to the fact that 3-way tcp connection is established prior to "Accept incoming connection attempt?" pop up, moreover on top of that it seems one can sniff the server's version along with server's (running TWS) time before getting accepted! this is what java demo prints to std output before getting accepted: (quote) Server Version:76 TWS Time at connection:20160104 13:34:20 EST (end of quote) I'm not sure if any requests can be processed (if any) before you're accepted, I guess none. And then you have only so many seconds to click "yes" or "no" before TWS will brake established tcp-connection. (no time/desire to play with it now) Of cause it is a very lame security model. Imho if remote IP is not on "allowed" list they should never even be able to get SYN-ACK on initial connection attempt but TWS could notify us about the fact that someone from that IP at that time tried to knock the door. Less strict would be to behave similar as they do now, but never let any info to the client before formally accepted (or found in "allowed IPs" list), but in this case someone might DDoS your production TWS. Cheers, Dmitry On Mon, Jan 4, 2016 at 11:00 AM, jasonl534@... [TWSAPI] <TWSAPI@...> wrote:
--
§ã §é.§Ô§Ý.§å§Ó., §¥§Ú§Þ§Ñ §º. |
||||||||||||||||||||
I think most of us are bypassing the "Accept
incoming connection request" dialog by specifying a trusted
connection.? That is done on the TWS by clicking ,
, and <127.0.0.1> in Trusted IP
Addresses for local loop.
toggle quoted message
Show quoted text
[rwk] At 11:42 AM 1/4/2016, you wrote: I don't have an answer to your question but I have an alternative approach. |
||||||||||||||||||||
rholowczak
Best bet is to add your localhost ip address to "Trusted connections" and/or the IP address of the host where your application is running. I outlined how to do this in my tutorial on downloading, installing and setting up the IB Gateway and IB API on Linux. (But generally, same concept applies to Windows as well).
|
||||||||||||||||||||
to navigate to use esc to dismiss