API Support Forum
OEC API > API Support > Exception in API.dll
Author Topic: Exception in API.dll
(13 messages, Page 1 of 1)
Moderators: VPfau
CZendejas116
Posts: 51
Joined: Apr 13, 2011


Posted: Jul 14, 2011 @ 09:43 AM             Msg. 1 of 13
Hi,

I have an application that connects to OEC server, using:
oecClient.Connect(domain, 9200, user, pws, false);

And after that, app sends orders after some analysis over the data received from the same server.
This application sends few orders during its excecution (about 25 in one day), but after 24 hours aproximatly, my application stops its excecution because an exception, and I found than that exception is in API.dll
This is what I get in Visual Studio execution log:

...
The thread '<No Name>' (0x19c0) has exited with code 0 (0x0).
A first chance exception of type 'System.IndexOutOfRangeException' occurred in API.dll
A first chance exception of type 'System.IndexOutOfRangeException' occurred in API.dll
A first chance exception of type 'System.IndexOutOfRangeException' occurred in API.dll
A first chance exception of type 'System.AggregateException' occurred in mscorlib.dll
An unhandled exception of type 'System.AggregateException' occurred in mscorlib.dll

Additional information: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread.

The thread '<No Name>' (0x1a9c) has exited with code 0 (0x0).
...
The thread '<No Name>' (0x7f4) has exited with code 0 (0x0).
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
The program '[3968] OECSendsOrderApp.vshost.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).



I can see a System.IndexOutOfRangeException (in API.dll) and a System.Net.Sockets.SocketException. I do not use any socket, that makes me think in API.dll sockets (which stablish conection with OEC server).

Any idea why this exception occurs? Do I need to do something else to avoid this kind of exceptions? Is it possible that API.dll have a little issue?

Thank you so much in advance

Claudia Zendejas
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jul 15, 2011 @ 08:53 AM             Msg. 2 of 13
Claudia, could you please send me exact timestamp of the issue and username?

Victor Vins
Lead Software Developer
CZendejas116
Posts: 51
Joined: Apr 13, 2011


Posted: Jul 15, 2011 @ 12:42 PM             Msg. 3 of 13
Hi,

Timestamp when exception occurs is:
2011-07-13 20:55:56.4270748
This is what my log reports, so its my local time, in Mexico (-5 GMT)
In UTC time is 2011-07-14 01:55:56.4270748

Username: WRalph15
Account: DEMO367974

Regards

Claudia Zendejas
CZendejas116
Posts: 51
Joined: Apr 13, 2011


Posted: Jul 20, 2011 @ 03:26 PM             Msg. 4 of 13
any news about this issue?

Claudia Zendejas
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jul 20, 2011 @ 03:35 PM             Msg. 5 of 13
From server standpoint, connection from your application was lost, not closed by OECAPI. In the past I saw such situations when customers had issue with their Internet provider. Exceptions that you saw could be a side effect of unexpectedly lost connection.

Victor Vins
Lead Software Developer
CZendejas116
Posts: 51
Joined: Apr 13, 2011


Posted: Jul 20, 2011 @ 04:28 PM             Msg. 6 of 13
We had made several tests about lost connection. We removed ethernet cable and check what happens, in our app we implement OnDisconnectedEvent, and every time we lost connection, this event is fired. This event implementation reconects our app, and every time is reconnected sucessfully. Our Internet provider has left us without conecction a couple of times over several months, and we already check, when that exception occurred, our Internet provider didn't fail.
Also, in stacktrace, we can read "System.IndexOutOfRangeException occurred in API.dll", I don't really think this kind of exception is fired because a disconnection.
Could you please re-check this issue and tell us what is going on?
Currently we have try-catch sentences every where, even in Program.cs (Main method). We cannot manage exceptions that occurre in API.dll. And is very important that our app doesn't collapse.

Thank you so much in advance.

Claudia Zendejas
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jul 20, 2011 @ 04:43 PM             Msg. 7 of 13
Did you have enabled OEC Logs?

Victor Vins
Lead Software Developer
CZendejas116
Posts: 51
Joined: Apr 13, 2011


Posted: Jul 20, 2011 @ 04:54 PM             Msg. 8 of 13
No. How can we activate OEC Logs?
Exception that I mentioned that occur in API.dll was seen in Visual Studio output. But, in order to get more information, we can activate OEC Logs and try to reproduce same exception.

Claudia Zendejas
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jul 21, 2011 @ 01:16 PM             Msg. 9 of 13
You can enable writing logs from OECAPI by calling OEC.Log.Start() method.

Victor Vins
Lead Software Developer
CZendejas116
Posts: 51
Joined: Apr 13, 2011


Posted: Aug 03, 2011 @ 10:28 AM             Msg. 10 of 13
Same Exception occurred again!
This time we had OEC Logs enabled.

Output from Visual Studio 2010:
...
A first chance exception of type 'System.IndexOutOfRangeException' occurred in API.dll
A first chance exception of type 'System.AggregateException' occurred in mscorlib.dll
An unhandled exception of type 'System.AggregateException' occurred in mscorlib.dll
...

OEC API Log (Enabled with OEC.Log.Start();):

13:57:16.953 Dbg Reader Order Login to OEC Server 4.0.0.0
13:57:17.338 Dbg Reader Price PLogin to OEC Server 4.0.0.0
13:57:17.941 Dbg System #10 ASanchezTM : Loading
13:57:18.074 Dbg System #10 ASanchezTM : Loaded, API: 85.0049ms, Client: 48.0027ms
13:57:18.833 Dbg System #10 DOM RLM-MU1 : 734350.18:57:18.8323585
13:57:20.605 Dbg System #10 4 RLM-MU1: 1440 Bars <Bars Items=[1440] />
13:57:20.788 Dbg System #10 4 RLM-MU1: 1440 Bars <Bars Items=[1440] />
13:57:20.998 Dbg System #10 4 RLM-MU1: 1440 Bars <Bars Items=[1440] />
13:57:21.138 Dbg System #10 4 RLM-MU1: 988 Bars <Bars Items=[988] />
15:15:58.821 Dbg System #10 DOM RLM-MU1 : 00:00:07.1323264
...
16:31:42.549 Dbg System #10 DOM RLM-MU1 : 00:00:19.0952128
16:32:28.673 Dbg System #10 ASanchezTM : Account not found, balance 17905, 3
16:32:49.539 Dbg System #10 DOM RLM-MU1 : 00:01:06.0070445
...
16:59:43.749 Dbg System #10 DOM RLM-MU1 : 00:00:03.2343719
16:59:56.001 Dbg System #10 DOM RLM-MU1 : 00:00:09.9710727


Last timestamp in OEC API Log is 16:59:56.001
Last timestamp in My App Log is 2011-08-02 16:59:58.9352405

So, in that time occurred the exception, in my local time. In UTC time occurred at 11:59:58

I cannot see anything in OEC API Log, but my app collapse because a 'System.IndexOutOfRangeException' occurred in API.dll.

This time the error occurred while my app was connected to prod.openecry.com, with user ASanchezTM.


Could you help me to resolve this issue?


Thanks

Claudia Zendejas
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Aug 03, 2011 @ 02:33 PM             Msg. 11 of 13
Hello,

server log shows that our server pings stopped for this order connection and our server closed it.

Could you please clarify - was IndexOutOfRange exception unhandled by OEC API internally and it led to collapse? I see two other exceptions (AggregateException) in your log that are not a part of .NET 2 that is used by OECAPI.
CZendejas116
Posts: 51
Joined: Apr 13, 2011


Posted: Aug 03, 2011 @ 04:51 PM             Msg. 12 of 13
First of all, I apologize because of my English, it seems I don't express my ideas clearly, I'm really sorry and I apreciate your patience.

System.IndexOutOfRangeException occurs inside API.dll, and It wasn't handled it by OEC API, because this exception provokes to my app to stop its execution unexpectedly.
Internally into my app, I had lots of try-catch blocks (even in Main method), and any of them catched this exception (IndexOutOfRangeException), because we don't have any control of API.dll
I copied the other exceptions (AggregateException) from Visual Studio 2010 Output in order to give you some context. They were thrown because of the first one (IndexOutOfRangeException).

My app is being developed in .NET Framework 4.0, under Visual Studio 2010, app runs on Windows 7 and Windows Server 2008 R2. My app executes main processes into separate Threads, in order to improve performance. OEC API version is 3.5.0.0

I can check 3 different logs:
-Visual Studio 2010 Output (inside the IDE) <- here were shown the exception
-My App log (created by NLog) <- no exception registered
-OEC API Log <- no exception registered

Unfortunatly I don't have full stacktrace for this exception, it wasn't registered in any log, just the legend in Visual Studio 2010 Output:
"A first chance exception of type 'System.IndexOutOfRangeException' occurred in API.dll"
and immediately after, my app stops its execution.

Regards,

Claudia Zendejas
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Aug 04, 2011 @ 10:31 AM             Msg. 13 of 13
Claudia,

how did you realize a Windows message pump? I have a supposition that some call of OECAPI method (probably, from the application) raised an IndexOutRangeException and it led to exit from the main thread (= thread that created OECAPI instance). Events (and logs as consequence), pings stopped without this thread.

All exceptions that raised in OECAPI are handled internally, if the origin of stack trace is inside OECAPI instance. For example, exceptions inside internal threads, unhandled exceptions in event handlers.

To catch the full stack trace of unhandled exceptions I would recommend to implement AppDomain.UnhandledException event handler.