API Support Forum
OEC API > API Support > OEC Remoting
Author Topic: OEC Remoting
(36 messages, Page 1 of 2)
Moderators: VPfau
SierraChart
Posts: 111
Joined: Jul 17, 2007


Posted: Oct 15, 2009 @ 01:26 PM             Msg. 1 of 36
We have been confused by the Remoting feature. And we've had problems using it. We have been discussing this by e-mail. We will continue the discussion here so that it can be helpful to others.

What we have learned is that it is first necessary to run OEC Trader first and then the other application which will use the same API instance. This is what we are doing:

1. Start OEC trader and login
2. We create the API with this:

m_API = OEC::API::OECClient::CreateInstance(true);
We call the API Connect function.

3. We get a "login failed. User is connected from another location." error message.

4. We get a OnDisconnected callback. We go through the normal disconnect sequence which involves calling the API Disconnect function.

5. We connect again and it is successful.

6. When we close the "login failed" box that displayed in 3, we get a OnLoginFailed callback with the reason "UserAlreadyConnected". We then Disconnect again and connect to the API. The connection succeeds.

Thank You,
Sierra Chart Engineering
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Oct 15, 2009 @ 02:21 PM             Msg. 2 of 36
Could you please specify some details: what values did you have in m_API->RemoteHostingEnabled and in m_API->ConnectionClosed right after m_API = OEC::API::OECClient::CreateInstance(true) in #2?

Our sample is using the next logic:

void CCppCOMSampleDlg::OnBnClickedConnect()
{
CheckOECAPI();
if(OECAPI()->RemoteHostingEnabled)
log << "Remoting Enabled" << std::endl;
if(OECAPI()->ConnectionClosed)
{
CLoginDlg dlg;
if(dlg.DoModal()== IDOK)
{
OECAPI()->Connect((LPCSTR)dlg.Server(), 9200, (LPCSTR)dlg.Username(), (LPCSTR)dlg.Password(), VARIANT_TRUE);
log << "Start connecting..." << std::endl;
}
}
}

If both these values are TRUE, your application initiates one more connection over existing one. The same effect can be reproduced, if the application will use a local instance of API and will call Connect without any checking of the current connection status.
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Oct 15, 2009 @ 02:22 PM             Msg. 3 of 36
Update. Please read "If both these values are TRUE" as "m_API->RemoteHostingEnabled == TRUE" and "m_API->ConnectionClosed == FALSE".
SierraChart
Posts: 111
Joined: Jul 17, 2007


Posted: Oct 15, 2009 @ 04:52 PM             Msg. 4 of 36
We are going to have to look at this tomorrow. We will get back to you.

Thank You,
Sierra Chart Engineering
SierraChart
Posts: 111
Joined: Jul 17, 2007


Posted: Oct 20, 2009 @ 05:46 PM             Msg. 5 of 36
Connecting to Open E Cry server: sim.openecry.com:9200... - 2009-10-20 14:45:27
Open E Cry - RemoteHostingEnabled: True, ConnectionClosed: False - 2009-10-20 14:45:27
Lost the connection to Open E Cry. - 2009-10-20 14:45:28
Error connecting to data or trade service. For more information, press the Send For Analysis button. - 2009-10-20 14:45:28
Disconnected from Open E Cry. - 2009-10-20 14:45:28
Will reconnect to the server in 5 seconds. To cancel, select File >> Disconnect on the menu. - 2009-10-20 14:45:28

Thank You,
Sierra Chart Engineering
SierraChart
Posts: 111
Joined: Jul 17, 2007


Posted: Oct 20, 2009 @ 05:48 PM             Msg. 6 of 36
At this point using this remoting feature is causing different unexpected issues. We have been told by one of your support people that when SC connects, the user gets disconnected from OEC Trader. We have also heard from another user that they seem to get disconnected relating to when they try to find contracts.

Thank You,
Sierra Chart Engineering
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Oct 21, 2009 @ 08:10 AM             Msg. 7 of 36
Did SC call Connect(..) method even ConnectionClosed was False?
SierraChart
Posts: 111
Joined: Jul 17, 2007


Posted: Oct 21, 2009 @ 12:02 PM             Msg. 8 of 36
Yes we did.

Thank You,
Sierra Chart Engineering
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Oct 21, 2009 @ 12:13 PM             Msg. 9 of 36
This is a reason: Connect(...) shouldn't be called, if ConnectionClosed = false.
SierraChart
Posts: 111
Joined: Jul 17, 2007


Posted: Oct 24, 2009 @ 10:30 PM             Msg. 10 of 36
We are no longer calling the API Connect function when ConnectionClosed == false.

However, OEC Trader still pops up an error message relating to login after calling:
m_API = OEC::API::OECClient::CreateInstance(true);

Also, what happens to OEC Trader if it is later started when a user has specified a different username in Sierra Chart and we do call the Connect function because the connection is closed.

Thank You,
Sierra Chart Engineering
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Oct 26, 2009 @ 07:14 AM             Msg. 11 of 36
Actually, CreateInstance method doesn't initiate any operation with server connection. Could you please modify our CppCOMSample from OEC API COM installation to reproduce this issue?

If OEC Trader was started after Sierra Chart, it will initiate own connection to OEC Server, not shared with Sierra Chart's one.
SierraChart
Posts: 111
Joined: Jul 17, 2007


Posted: Oct 27, 2009 @ 02:02 PM             Msg. 12 of 36
One of the developers did a test and did not see any error indicating a login problem from OEC Trader when connecting Sierra Chart, so at this point we will just let this go for now and see if we have other reports of it.

Thank You,
Sierra Chart Engineering
CChen15
Posts: 121
Joined: Jul 23, 2009


Posted: Oct 30, 2009 @ 04:41 AM             Msg. 13 of 36
I'm trying to create client application in Excel based on sample code coming with last API bundle.

I have read all the material on this forum regarding the CreateInstance (True), read
http://www.openecry.com/api/api/OEC.API.OECClient.CreateInstance.html , read
http://www.openecry.com/api/OECAPIRemoting.pdf

I studied all the examples in these materials.
I'm stupid beginner, I hardly speak English, but I'm well read.
And I see that CreateInstance is member of OECAPICOM.APIHelper only.
And I used following initialize string:

Public Sub IniClient()
Dim e As New OECAPICOM.APIHelper
Set e = New OECAPICOM.APIHelper
Rem If (cCli Is Nothing) Then Set cCli = New OECAPICOM.OECClient
If (cCli Is Nothing) Then Set cCli = e.CreateInstance(True)
End Sub

Please, show me how to initialize the client with parallel running terminal. Who must start first? Terminal with checked Allow Remoting or client application?

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Chen Hua, Russia
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Oct 30, 2009 @ 10:24 AM             Msg. 14 of 36
To allow remoting client to connect, OEC Trader should be started first.
CChen15
Posts: 121
Joined: Jul 23, 2009


Posted: Oct 30, 2009 @ 11:32 AM             Msg. 15 of 36
I appreciated your conciseness. Please give an example of a correct client initialization using CreateInstance.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Chen Hua, Russia
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Oct 30, 2009 @ 11:34 AM             Msg. 16 of 36
Set cCli = e.CreateInstance(True)
CChen15
Posts: 121
Joined: Jul 23, 2009


Posted: Oct 30, 2009 @ 11:50 AM             Msg. 17 of 36
And you wan't to say any words about
Quote: Creates an instance of OECClient or connects remotely to exposed one, if searchRemoteAtFirst is true

public static OECClient CreateInstance(
Boolean searchRemoteAtFirst
);


and about
Quote: 3. This is the OEC Remote instance that connects to the exposed API of the primary 
application.(Remote enabled) 
OEC.API.OECClient OECClient = OEC.API.OECClient.CreateInstance(true);


Where is OECAPICOM.APIHelper in this quotes from official manuals I carefully reading?

Where is truth?
.


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

Edited by CChen15 on Oct 30, 2009 at 11:51:29
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Oct 30, 2009 @ 01:03 PM             Msg. 18 of 36
The documentation you are quoting is intended for C#/.NET developers who are able to call static methods directly.

COM does not support static methods, so you should use APIHelper object, which wraps static API calls.
CChen15
Posts: 121
Joined: Jul 23, 2009


Posted: Oct 31, 2009 @ 12:18 AM             Msg. 19 of 36
Thank you very much. I mentioned earlier that I'm a beginner. I hope it forgives me.

I'm coding on VBA under Excel & Access. Is there any other manuals adapted for it or there is Excel sample coming with API distr only?
.

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


Posted: Nov 01, 2009 @ 11:20 AM             Msg. 20 of 36
There are nothing works...

So I can't connect "Sample COM Book.xls" simultaneously with terminal. Below are my actions:
1. There are the following changes were made in the source code
Public Sub Connect(Name As String, Pass As String, Reconnect As Boolean)
On Error GoTo Err
If c Is Nothing Then
Rem Set c = New OECAPICOM.OECClient
Dim e As New OECAPICOM.APIHelper
Set e = New OECAPICOM.APIHelper
Set c = e.CreateInstance(True)
Rem Server = "api.openecry.com"
Server = "prod.openecry.com"
End If
c.Connect Server, 9200, Name, Pass, Reconnect
Exit Sub
Err:
MsgBox Err.Description
End Sub


2. Terminal was started and the "Allow Remoting" checkbox was checked.
3. Pressed "Connect" button in Excel
4. Terminal message "Login failed. User is connected from another location." appears. OK pressed.
5. Terminal was disconnected with changing status to red "Disconnected"
6. Excel status not changed
7. Press "Connect" button in Excel again
8. Get Excel message "Run-time error'430' Class does not support Automation etc. ..." and there are no possibility to swith to terminal window.
9. Press "Debug" and see that error is in "Public Sub UpdateStatus()" (page "Config")at command "Glob.c.RequestContracts Glob.c.BaseContracts.FindBySymbol("ESH9")"
10. Excel error message appear again.
11. When "End" was pressed in debugger the termminal was automatically reconnected and swithed its status to "Connected".

Video on http://ampfutures.narod.ru/OEC/OEC/Video_2009-11-01_154031.wmv (1.5MB)


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

Edited by CChen15 on Nov 1, 2009 at 11:20:56