Join the 80,000 other DTN customers who enjoy the fastest, most reliable data available. There is no better value than DTN!

(Move your cursor to this area to pause scrolling)




"If you are serious about your trading I would not rely on IB data for serious daytrading. Took me a while to justify the cost of IQ Feed and in the end, it's just a 2 point stop on ES. Better safe than sorry" - Comment from Public Forum
"Just a quick one to say I'm very impressed so far :) The documentation for developers is excellent and I've quickly managed to get an app written to do historical downloads. The system is very robust and pretty quick considering the extent of data that's available. The support guys have been very helpful too, in combination with the forums it's been plain sailing so far!" - Comment from Adam
"I am very pleased with the DTNIQ system for quotes and news." - Comment from Larry
"I was on the phone with a friend who uses CQG and right after the Fed announcement, CQG was as much as 30 seconds behind DTN.IQ. Some quotes were off by as much as 15-18 cents. Your feed never missed a beat." - Comment from Roger
"Thanks for following up with me. You guys do a great job in tech support." - Comment from Phelps
"You are much better than lawyers or the phone company because you answer the phone when I call! I just love your customer service." - Comment from Isreal
"Thanks for the great product and support. During this week of high volume trading, my QuoteTracker + IQ Feed setup never missed a beat. Also, thanks for your swiftness in responding to data issues. I was on ******* for a few years before I made the switch over early this year, and wish I had done it a long time ago." - Comment from Ken
"Awesome response, as usual. It is a sincere and refreshing pleasure to do business with DTN, compared to your competition." - Comment from Ryan
"I'm satisfied with IQFeed. It's the most reliable and fastest quote feed I have ever used. Although I'm a resident in China, it's still very fast!" - Comment from Xiaofei
"I had always used ******* but for the past 2 weeks have been trying DTN IQFeed. Customer support has been extraordinary. They call just to make sure your problem hasn't recurred." - Comment from Public Forum
Home  Search  Register  Login  Recent Posts

Information on DTN's Industries:
DTN Oil & Gas | DTN Trading | DTN Agriculture | DTN Weather
Follow DTNMarkets on Twitter
DTN.IQ/IQFeed on Twitter
DTN News and Analysis on Twitter
»Forums Index »Archive (2017 and earlier) »IQFeed Developer Support »Connection Refused error
Author Topic: Connection Refused error (7 messages, Page 1 of 1)

jonnyb
-DTN Evangelist-
Posts: 122
Joined: Aug 15, 2012


Posted: Apr 29, 2022 09:46 AM          Msg. 1 of 7
Hello,

After using the same code to connect for many years, I'm suddenly having an issue with connecting to the socket admin port (connection refused socket exception). I can resolve the issue by pausing the thread for a few seconds, but I'm curious why this is now necessary. Appreciate any input on what might have changed. Here's the code below with some notes on what's different:

 
Process process = new ProcessBuilder("iqconnect.exe", "my login stuff").start();

ThreadUtils.pause(5000); //<-------------------------------THIS WAS NOT NECESSARY IN THE PAST

System.out.println("Verifying if IQConnect is connected to the server");

// verify everything is ready to send commands.
boolean bConnected = false;

// connect to the admin port (9300).
Socket sockAdmin = new Socket(InetAddress.getByName("localhost"), 9300);//<---------------------------CONNECTION REFUSED ERROR THROWN AT THIS LINE

BufferedReader bufreadAdmin = new BufferedReader(new InputStreamReader(sockAdmin.getInputStream()));
BufferedWriter bufwriteAdmin = new BufferedWriter(new OutputStreamWriter(sockAdmin.getOutputStream()));
String strAdminLine = "";

// loop while we are still connected to the admin port or until we are connected
while (((strAdminLine = bufreadAdmin.readLine()) != null) && !bConnected)
{
System.out.println(strAdminLine);

if (strAdminLine.indexOf(",Connected,") > -1)
{
System.out.println("IQConnect is connected to the server.");
bConnected = true;
}
else if (strAdminLine.indexOf(",Not Connected,") > -1)
{
System.out.println("IQConnect is Not Connected.\r\nSending connect command.");
bufwriteAdmin.write("S,CONNECT\r\n");
bufwriteAdmin.flush();
}
}


DTN_Gary_Stephen
-DTN Guru-
Posts: 400
Joined: Jul 3, 2019


Posted: Apr 29, 2022 10:46 AM          Msg. 2 of 7
Nothing has changed on our end. IQFeed wouldn't block you from connecting to the Admin socket. I suspect something external is using port 9300, or otherwise interfering with traffic to it. You can find this in Command Prompt. Send this command:

netstat -ano | findStr “9300”


This will turn up one or more lines like this:


C:\Users\Gary.Stephen>netstat -ano | findStr "9300"
TCP 127.0.0.1:9300 0.0.0.0:0 LISTENING 17736
TCP 127.0.0.1:9300 127.0.0.1:59229 ESTABLISHED 17736
TCP 127.0.0.1:59229 127.0.0.1:9300 ESTABLISHED 21048


The number on the far right is the process ID. To find what each one represents, enter this on the command line. (The actual numbers will vary. Change the number, and repeat the command once for each number, as appropriate.)

tasklist /fi "pid eq 17736"


And this will tell you exactly what’s using the port:

Image Name PID Session Name Session# Mem Usage

========================= ======== ================ =========== ============
iqconnect.exe 17736 Console 1 17,112 K


iqconnect.exe is what you want to be using to be port 9300, but see if this discovers that some rogue app is using it. You can then decide what to do: reconfigure it or IQFeed to use something else (see below), or just disable the conflicting app.

Other comments:

  • A Logitech app called lghubupdater commonly interferes with port 9100 in this way. Most people just disable that app to resolve the conflict.

  • It is possible to customize what port numbers IQFeed uses, by making registry changes in Computer\HKEY_CURRENT_USER\Software\DTN\IQFeed\Startup. I recommend caution when doing this, though, because third-party software (and third-party code bases) don't always implement this.

  • Make sure you have whitelisted the entire IP range IQFeed uses, which is: 12.36.218.128 – 12.36.218.254 (CIDR: 12.36.218.128/25), Ports: 60000-60060. I don't think that's the issue here, but it's always good to make sure of this.


I hope this helps! Beyond that, I'd need to get more information from you. You can send me a support email or chat, and I will investigate further.

Sincerely,
Gary Stephen
DTN IQFeed Implementation Support Specialist

jonnyb
-DTN Evangelist-
Posts: 122
Joined: Aug 15, 2012


Posted: Apr 29, 2022 02:38 PM          Msg. 3 of 7
Thank you, Gary! I will work through this on Monday. The odd thing for me is that pausing the thread for a few seconds makes the issue go away...I'll have to be nimble with my command prompts.

jonnyb
-DTN Evangelist-
Posts: 122
Joined: Aug 15, 2012


Posted: May 2, 2022 08:28 AM          Msg. 4 of 7
Good morning, Gary.

I've had a chance to play around with this little and nothing gets returned for the netstat call on 9300. Given that and the fact that the issue goes away if I delay a few seconds after starting iqconnect.exe, it seems that the connection is getting refused because there's nothing at 9300 yet (until iqconnect.exe fully loads).

Can that be what's going on? If so, it's very odd that a timing issue would suddenly arise after years of running the same code. Also, the DTN samples are written without a thread delay, so seems unlikely that this behavior would be possible.

Anyhow, I do have a workaround, but I'd really like to understand the behavior of what's happening, if possible. Appreciate any further input.
Edited by jonnyb on May 2, 2022 at 08:30 AM

DTN_Gary_Stephen
-DTN Guru-
Posts: 400
Joined: Jul 3, 2019


Posted: May 4, 2022 11:30 AM          Msg. 5 of 7
Can you provide a iqconnect.txt log file, with all logging turned on? You can send it to me at the developer support address. A "Test" on the IQConnect tab of the Diagnostics app would be helpful also.

Sincerely,
Gary Stephen
DTN IQFeed Implementation Support Specialist

jonnyb
-DTN Evangelist-
Posts: 122
Joined: Aug 15, 2012


Posted: May 6, 2022 01:54 PM          Msg. 6 of 7
I inserted this after the ProcessBuilder line and it seems to do the job. Perhaps, it's a slight improvement over simply pausing the thread. Maybe it'll help someone else in the future. Anyway, thanks for offering to look into to it further but not sure it's worthwhile investing more time (of course, that assumes the problem doesn't come back). Thanks again.

 
Socket sockAdmin = null;
int retryCounter = 0, threshold = 15;

while (retryCounter < threshold && sockAdmin == null)
{
try
{
retryCounter++;

// connect to the admin port (9300).
sockAdmin = new Socket(InetAddress.getByName("localhost"), 9300);
}
catch (ConnectException e)//host and port combination not valid
{
e.printStackTrace();

ThreadUtils.pause(2500);
}
}

DTN_Gary_Stephen
-DTN Guru-
Posts: 400
Joined: Jul 3, 2019


Posted: May 10, 2022 08:22 AM          Msg. 7 of 7
I'm glad you were able to work around the problem! Thanks for letting me know.

Sincerely,
Gary Stephen
DTN IQFeed Implementation Support Specialist
 

 

Time: Sun June 16, 2024 12:41 AM CFBB v1.2.0 11 ms.
© AderSoftware 2002-2003