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'm very glad I switched to IQFeed. It's working perfectly with no lag, even during fast market conditions." - Comment from Andy via Email
"I cannot believe what a difference it makes trading with ProphetX!" - Comment from Bruce in Los Angeles
"Everything is working amazing now. I'm already impressed with the true-tick feed of IQFeed and it's ability to support my 480 symbol layout." - Comment from Tyler via Email
"I started a trial a few weeks back before the market went wild. DTN.IQ didn’t miss anything and beat my other provider. I decided to stay with you because of the great service through all the volatility." - Comment from Mike
"This beats the pants off CQG, I am definitely switching to the ProphetX 3.0!" - Comment from Stephen
"Everything is working great with the API. I love it." - Comment from Calvin
"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
"After all the anxiety I had with my previous data provider it is a relief not to have to worry about data speed and integrity." - Comment from Eamonn
"With HUGE volume on AAPL and RIMM for 2 days, everyone in a trading room was whining about freezes, crashes and lag with *******, RealTick, TS and Cyber. InvestorRT with IQFeed was rock solid. I mean SOLID!" - Comment from Public IRC Chat
"Excellent datafeed !!!" - Comment from Arely
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 11:23 AM CFBB v1.2.0 6 ms.
© AderSoftware 2002-2003