Auto failover does not work with multi credential if connection failed when constructing OmmConsumer

LennonLam
LennonLam Newcomer
edited February 6 in EMA

Hello,

Is the auto failover mechanism wont work with multiple credential if connection failure happens in OmmConsumer constructor? Here is my env and repeat steps:

RTSDK: 2.2.3.E1
Lang: C++
OS: Redhat 7

In my env, we have 2 servers which can be logon with 2 different usernames. Let say
Server_A: username = User_A
Server_B: username = User_B
The <ChannelSet> in EmaConfig.xml is set to "Server_A, Server_B".

My application start with the following code snippet to create OmmConsumer:

class AppLoginClient : public OmmLoginCredentialConsumerClient
{
    void onLoginCredentialRenewal(const OmmConsumerEvent& consumerEvent)
    {
        // Update login name to "User_B"
        LoginMsgCredentialRenewal credentialRenewal;
        credentialRenewal.userName( EmaString( "User_B") );
        consumer->renewLoginCredentials( credentialRenewal );
    }
};

……

AppLoginClient loginClient; // Inherit OmmLoginCredentialConsumerClient

Login::LoginReq* login = new Login::LoginReq;
login->name( EmaString("User_A") );

OmmConsumerConfig cfg ( EmaString( "./EmaConfig.xml") );
cfg.addLoginMsgCredential( login->getMessage(), EmaString( "Server_A, Server_B") , loginClient, (void*)login );

OmmConsumer consumer( cfg );

In the above code, I expect to receive onLoginCredentialRenewal callback to update login name on any connection issue happened in Server_A.

However, if connection to Server_A failed in the OmmConsumer constructor, RealtimeSDK will connect to Server_B automatically but login with "User_A", and the onLoginCredentialRenewal() is not called.

Checked the logic in OmmBaseImpl::loginCredentialCallback() in OmmBaseImpl.cpp,
onLoginCredentialRenewal() will only be called if pBaseImpl->isInitialized() is true.

Could you please advice how application can change the username when constructing OmmConsumer?

Thanks

Best Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    @LennonLam

    Thank you for reaching out to us.

    I checked with the Con480 example in the package, by using the following parameters.

    -LoginMsg name:user1  channelList:Channel_1 -LoginMsg name:user2  channelList:Channel_2
    

    The example works properly. It uses the user1 to connect o Channel_1 and uses the user2 to connect to Channel_2 although the Channel_1 failed at startup.

    Please test it with the Con480 example.

    To confirm the behavior in the OmmConsumer's constructor, please contact the API support team directly via Contact Premium Support. Otherwise, you can raise this issue on GitHub.

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    @LennonLam

    Yes, it is an expected behavior. When the username is invalid, the server will close the login stream. API will not perform connection recovery when the login stream is closed.

Answers

  • Hello @Jirapongse

    Thanks for your quick reply. Tested with Con480 and multi credential works.

    One more question, will EMA perform failover if server is up but login fail?
    I tested with an invalid username on Channel_1 and a valid username on Channel_2. OmmConsumer constructor throws "OmmInvalidUsageException" without trying to connect to Channel_2. Is this expected?

    Thanks