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)




"I would just like to say that IQFeed version 4 is running very well and I am very happy with its performance. I would also like to extend a big thanks for the fast and efficient help that I always receive. My questions and concerns are always addressed promptly. Way to go!" - Comment from Josh in CO.
"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
"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
"IQ feed is brilliant. The support is mind-bending. What service!" - Comment from Public Forum Post
"I "bracket trade" all major news releases and I have not found one lag or glitch with DTN.IQ feed. I am very comfortable with their feed under all typical news conditions (Fed releases, employment numbers, etc)." - Comment from Public Forum
"Very impressed with the quality of your feed - ******* is a real donkey in comparison." - Comment from A.C. via Email
"If someone needs the best quality data and backfill beyond what their broker provides at a rate that is the best in the industry, I highly recommend IQFeed." - Comment from Josh via Public Forum
"You have an excellent feed. Very few spikes for Spot Forex." - Comment from Public Forum Post
"Its working FABULOUSLY for me!! Holy cow...there has been so much I've been missing lately, and with this feed and Linnsoft software...I'm in the game now." - Comment from Chris R.
"Thank God for your Data Feed as the only Zippers I see are on my pants (LOL), and no more 200 pip spikes to mess up charts." - Comment from Spiro via Email
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: 379
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: 379
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: 379
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: Thu December 7, 2023 3:52 AM CFBB v1.2.0 18 ms.
© AderSoftware 2002-2003