API Support Forum
OEC API > API Support > OECAPI 3.5; Excel example; Disconnection troubles
Author Topic: OECAPI 3.5; Excel example; Disconnection troubles
(13 messages, Page 1 of 1)
Moderators: VPfau
CChen15
Posts: 121
Joined: Jul 23, 2009


Posted: Jun 03, 2010 @ 11:58 AM             Msg. 1 of 13
Hello.

I have troubles with Excel example included in bundle of OECAPI 3.5 downloaded by link
http://api.openecry.com/Sections/Misc/DownloadFile.aspx?ClientUpdate=0_5003_1

Changes in code were made in one line only:

OECClass module --> Connect() procedure
Rem Server = "api.openecry.com"
Server = "prod.openecry.com"
or
Server = "sim.openecry.com"

Once the connection to Excel successfully installed, I run the terminal OEC Trader and the following message appears in Excel:
http://img375.imageshack.us/img375/2792/0603082426.png
---------------------------
Microsoft Excel
---------------------------
Application-defined or object-defined error
---------------------------
OK
---------------------------

After pressing OK button, the following message appears:
http://img535.imageshack.us/img535/5434/0603082613.png
---------------------------
Microsoft Excel
---------------------------
Login Failed: UserAlreadyConnected
---------------------------
OK
---------------------------

I press Ok button, however connection status cells "B9:C9" are lights in green and have value "Status: Connected".
http://img36.imageshack.us/img36/2032/0603082710.png

I understand the reason of second message, but not the first. Explain me please this situation with the first error message.

Thank you.

**********************************
OS Win XP Pro SP2, clear installation
Office 11 SP3 Ru; Excel and Access only in minimum configuration
.Net FW 2.0 SP2
OEC API 3.5
OEC Trader 3.5.09

No other programs installed.
.



- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Chen Hua, Russia

Edited by CChen15 on Jun 3, 2010 at 11:59:33
Edited by CChen15 on Jun 3, 2010 at 12:01:19
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jun 03, 2010 @ 12:45 PM             Msg. 2 of 13
The first message means a bug in the Excel sample. The sample is not intended to use in production and doesn't cover all possible situations.
CChen15
Posts: 121
Joined: Jul 23, 2009


Posted: Jun 03, 2010 @ 01:09 PM             Msg. 3 of 13
What you can recommend me?

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Chen Hua, Russia
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jun 03, 2010 @ 01:50 PM             Msg. 4 of 13
I recommend do not use the sample in production.
CChen15
Posts: 121
Joined: Jul 23, 2009


Posted: Jun 03, 2010 @ 02:36 PM             Msg. 5 of 13
I don't use it in production, but I explore the connection-disconnection proccesses and took as a basis the kind offer sample by OEC. You say that this sample is the error-full kind of code... OK.

Are you ready to look at my own simple code with same error?

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Chen Hua, Russia
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jun 04, 2010 @ 08:15 AM             Msg. 6 of 13
Yes, I'm ready.
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jun 04, 2010 @ 12:42 PM             Msg. 7 of 13
Excel doesn't allow to show message box and change worksheet at once. In the new version of the sample the message box will be removed to avoid this error message.

Victor Vins
Software Developer
CChen15
Posts: 121
Joined: Jul 23, 2009


Posted: Jun 06, 2010 @ 05:17 PM             Msg. 8 of 13
Dear Victor,

Thank you for accept to look at my code. But, when I prepared and debugged it, my application suddenly could not connect to the server. It was disconnectend immediately after connection was established (ConnectionClosed = False). I have checked the situation through the terminal OECTrader 3.4.0.8 and got the following message:
Quote: System Error: Connect to OEC Server failed. Please check your internet connection.
No connection could be made because the target machine actively refused it.

http://img63.imageshack.us/img63/8908/0606203701.png

I have three questions in this regard:

1. Why I didn't get this message through API?

2. I looked through all the documentation but could not find an answer to the question: which instructions and/or function should I use to get the same message when a connection is established through the API?

3. Why, at the same time, I was quietly connected to the real server (prod) using real login-passvord?

Sorry for digression of theme.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Chen Hua, Russia
CChen15
Posts: 121
Joined: Jul 23, 2009


Posted: Jun 06, 2010 @ 05:23 PM             Msg. 9 of 13
Quote: Excel doesn't allow to show message box and change worksheet at once...
--- Original message by VictorV on Jun 4, 2010 12:42 PM
Yes. I have a symbate thoughts. But my experiments was unexpectedly interrupted (see post above). I will return to this issue later.


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Chen Hua, Russia

Edited by CChen15 on Jun 6, 2010 at 17:23:47
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jun 07, 2010 @ 08:44 AM             Msg. 10 of 13
>> 1. Why I didn't get this message through API?

You should process OnError event in your application.

>> 2. I looked through all the documentation but could not find an answer to the question: which instructions and/or function should I use to get the same message when a connection is established through the API?

OnLoginComplete

3. Why, at the same time, I was quietly connected to the real server (prod) using real login-passvord?

Because SIM, Developement and Productions servers are different servers.

Please send me your username, date/time and server that refused your connection.

Victor Vins
Software Developer
CChen15
Posts: 121
Joined: Jul 23, 2009


Posted: Jun 07, 2010 @ 09:48 AM             Msg. 11 of 13
IMO, I'm doing a big mistake surely trusting the code in examples provided with the API ... I have look to example once more - error handler is commented in the procedure c_OnLoginComplete() by the developers. I have a long time ago paid attention to it, but I decided that this Rem was not accidental.

Do you think that it's strange that in the beginning you send examples with crude code inside, next you say that it is better not to use them in production (your messages No 2 & 4 in this thread http://www.openecry.com/cfbb/index.cfm?page=newreply&topicID=380"eID=1527#NEWMSG), and finally you recommend to change it up to the contrary as previously done yourself (not personally you but the one of developers, I mean)?

I understand that these are different servers. It seems that I vaguely expressed my thoughts in English again. Comparing the situation on different servers I mean that some events and premises had occurred to dropping the connection on one server, which was not on another server. What it could be the cause and how user can diagnose this situation that could arise again in a real trades?

I was trying to connect getting mentioned errors from TFurs account at 2010-06-06 20:40 GMT (according to screen date-time creation) to sim.openecry.com


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Chen Hua, Russia

Edited by CChen15 on Jun 7, 2010 at 09:49:14
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jun 07, 2010 @ 10:08 AM             Msg. 12 of 13
You have messed up Visual Basic exception handlers (that is really commented out in OnLoginCompleted to pass exceptions to OECAPI to initiate disconnecting in the case of errors) and OECAPI event OnError that looks like this one:

Private Sub c_OnError(ByVal ex As mscorlib.Exception)
rem add your code here
End Sub


About connection: I see your connections up to 06/06/2010
18:00:43.267 EST from three different IP addresses. After that I don't see any attempts to connect from them.

Victor Vins
Software Developer
CChen15
Posts: 121
Joined: Jul 23, 2009


Posted: Jun 07, 2010 @ 10:59 AM             Msg. 13 of 13
No-no. I haven't messed its.

However, you are right - there are no c_OnError(...) lines in my code. I has simplified the code as possible and leave only connect-reconnect the procedures in it. Thank you for remind it me. My production project is refered to mscorelib.dll long time ago and have following lines in it:

Private Sub cCli_OnError(ByVal ex As mscorlib.Exception)
Debug.Print "mscorlib.Exception Err: " & ex
End Sub

I don't remember there I got it :)

There was no one time this code was to work in and I exclude it bravely from connection test project...

>> ... that is really commented out in OnLoginCompleted to pass exceptions to OECAPI to initiate disconnecting in the case of errors ...

I note it for myself. And now I think that there are Excel and OECAPI events interference that isn't clear controlled by me. I will check my connection test code and repair it accordingly your remarks (I need some time for it). Thank you.


>> ... from three different IP addresses ...
Yes. In same time I saw troubles from my ISP. They was appear about two-three hours. After that, when my internet connection became stable, I wrote my post.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Chen Hua, Russia