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 am very happy I changed. I love the product, but more so I am thrilled with Tech Support. You are knowledgeable, polite, pleasant and professional." - Comment from Pat
"I ran your IQFeed DDE vs. my broker vs. a level II window for some slow-moving options. I would see the level II quote change, then your feed update instantaneously. My broker's DDE, however, would take as much as 30 seconds to update. I am not chasing milliseconds, but half a minute is unacceptable." - Comment from Rob
"DTN has never given me problems. It is incredibly stable. In fact I've occasionally lost the data feed from Interactive Brokers, but still been able to trade because I'm getting good data from DTN." - Comment from Leighton
"Can I get another account from you? I am tired of ******* going down so often" - Comment from George
"You are either overstaffed or people just don't have problems with your feed because customer support always answers the phone quickly." - Comment from Jay via Email
"And by the way, have to say this. I love the IQFeed software. It's rock solid and it has a really nice API." - Comment from Thomas via RT Chat
"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
"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
"I just wanted to let u know that your data feed/service is by far the best!!! Your unfiltered tick data is excellent for reading order flow and none of your competitors delivers this quality of data!" - Comment from Peter via Email
"My broker in Davenport suggested I give you a try as he uses your service and says its the best." - Comment from Bill via RT Chat
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 »Problem closing down and the restart
Author Topic: Problem closing down and the restart (3 messages, Page 1 of 1)

fng
-Interested User-
Posts: 31
Joined: Aug 2, 2007


Posted: Jun 28, 2010 08:51 AM          Msg. 1 of 3
I am running a program where I use some of the code you have in your demo program.

I have the program to close down and restart if I do not get any data in 30 sec.

When the close happens this is the code that is executed correctly:

Private Sub Level1Socket_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Try
RemoveClientApp(Me.Handle.ToInt32)
FileLog("DTNIQ Close Event - Correct Close Down!")
Catch ex As Exception
FileLog("CATCH Error in DTNIQ Close Down! " & ex.Message)
End Try
End Sub
According to my log this works fine.

BUT - sometimes when I try to restart the program I get this error from the Onconnect sub:

"No connection could be made because the target machine actively refused it 127.0.0.1:5009"

THIS IS the ONCONNECT SUB:

Public Sub OnConnect()
Try
m_sockIQConnect = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Dim ipLocalhost As IPAddress = IPAddress.Parse("127.0.0.1")
Dim iPort As Integer = GetLevel1Port()
Dim ipendLocalhost As Net.IPEndPoint = New IPEndPoint(ipLocalhost, iPort)
m_sockIQConnect.Connect(ipendLocalhost)

WaitForData()
'If everything OK then start Timer
'----------------------------------------------------------------
btnWatch.Enabled = True
btnWatch.PerformClick()
FileLog("Onconnect OK - Watch and Timer Start")
Timer1.Start()
'--------------------------------------------------------------
Catch ex As Exception
FileLog("Error from OnConnect: " & ex.Message)
Me.Close()
End Try
End Sub

To me it looks like the RemoveClientApp sometimes does not close the connection, any suggestions please!
Catch ex As Exception
FileLog("CATCH Error in DTNIQ Close Down! " & ex.Message)
End Try
End Sub
According to my log this works fine.

BUT - sometimes when I try to restart the program I get this error from the Onconnect sub:

"No connection could be made because the target machine actively refused it 127.0.0.1:5009"

THIS IS the ONCONNECT SUB:

Public Sub OnConnect()
Try
m_sockIQConnect = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Dim ipLocalhost As IPAddress = IPAddress.Parse("127.0.0.1")
Dim iPort As Integer = GetLevel1Port()
Dim ipendLocalhost As Net.IPEndPoint = New IPEndPoint(ipLocalhost, iPort)
m_sockIQConnect.Connect(ipendLocalhost)

WaitForData()
'If everything OK then start Timer
'----------------------------------------------------------------
btnWatch.Enabled = True
btnWatch.PerformClick()
FileLog("Onconnect OK - Watch and Timer Start")

Example from My LOG:
8:55:49 AM DTNIQ Close Event - Correct Close Down!
8:57:18 AM Error from OnConnect: No connection could be made because the target machine actively refused it 127.0.0.1:5009
8:57:18 AM DTNIQ Close Event - Correct Close Down!
8:57:33 AM Error from OnConnect: No connection could be made because the target machine actively refused it 127.0.0.1:5009

FNG

DTN_Steve_S
-DTN Guru-
Posts: 2093
Joined: Nov 21, 2005


Posted: Jun 28, 2010 10:39 AM          Msg. 2 of 3
FNG, the RemoveClientApp call doesn't actually shut down the feed. The only way to close the app is to either right-click the notification area icon and choose "Exit" from the menu or to disconnect all level 1 connections. IQConnect should exit automatically once there are no longer any connections to the level 1 port.

Also, I don't see anything in your code that actually launches the feed. If your app shuts down and IQConnect closes (as expected), then when you relaunch your app, there is nothing to connect to since IQConnect is no longer running which would cause the error message you are getting.

fng
-Interested User-
Posts: 31
Joined: Aug 2, 2007


Posted: Jun 28, 2010 12:34 PM          Msg. 3 of 3
Hi -thanks for your answer.
When the program loads it connect to DTN - Part of the code:

Dim sRes As Short = 1

'Dim dtn_port As Integer

Try

sRes = RegisterClientApp(Me.Handle.ToInt32, strProdID, strProdKey, strProdVersion)
If sRes <> 0 Then
FileLog("NO LogON - Close")
Me.Close() ' Restart from scheduler
End If

' ************************************* INIT Files *******************************************



'********************************************* Start Connection og Watch *********************************************************
dtn_port = GetLevel1Port()
OnConnect()

Catch ex As Exception
FileLog("Error Load IQConnect " & dtn_port)
Me.Close()
End Try
End Sub

I think it must have something to do with a thread which is still running when I try to close the program down. Does that sound correct?

Flemming
 

 

Time: Sat May 18, 2024 7:16 AM CFBB v1.2.0 9 ms.
© AderSoftware 2002-2003