question

Upvotes
Accepted
3 0 0 3

Port not closed after destroying OmmProvider

It seems that when the OmmProvider destructor is called, the server port is not closed properly. This causes some issues for us since we in the same process need to destroy and create the provider multiple times.


Example code:

#include <iostream>
#include <chrono>
#include <ctime>    
#include <thread>

#include "Ema.h"

using namespace refinitiv::ema::access;
using namespace refinitiv::ema::rdm;

class Gateway : public refinitiv::ema::access::OmmProviderClient
{
public:
    Gateway() : m_provider(OmmIProviderConfig("<insert EMA config file path here>"), *this) {}
    ~Gateway() { std::cout << "~Gateway()" << std::endl; }

    OmmProvider m_provider;

     void onReqMsg(
            const refinitiv::ema::access::ReqMsg &reqMsg,
            const refinitiv::ema::access::OmmProviderEvent &handle)
      {
            if (reqMsg.getDomainType() == MMT_LOGIN)
            {
                m_provider.submit(
                    RefreshMsg().
                    domainType(MMT_LOGIN).
                    name(reqMsg.getName()).
                    nameType(USER_NAME).complete().
                    attrib(ElementList().complete()).
                    solicited(true).
                    state(OmmState::OpenEnum, OmmState::OkEnum, OmmState::NoneEnum, "Login accepted"),
                    handle.getHandle());
            }
      }

    void onClose(
            const refinitiv::ema::access::ReqMsg &msg,
            const refinitiv::ema::access::OmmProviderEvent &handle)
            {
            }
            
};

int main(void)
{

for (int i = 0; i <  5; i++)
{    
    std::cout << "Creating gateway..." << std::endl;
    try {
            Gateway gwy;
    } catch (const OmmException & excp) {
            std::cerr << excp << std::endl;
            return 1;
    }
        std::this_thread::sleep_for (std::chrono::seconds(1));
    }

    return 0;
}

Output:

[tbricks@lsp7037c Ema]$ /tmp/provider
Creating gateway...
~Gateway()
Creating gateway...
Exception Type='OmmInvalidUsageException', Text='Failed to initialize OmmServerBaseImpl (Unable to bind RSSL server).' Error Id='-1' Internal sysError='98' Error Location='' Error Text='</local/jenkins/workspace/ESDKCore_RCDEV/OS/RH6-64/rcdev/source/rtsdk/Cpp-C/Eta/Impl/Transport/ripcutils.c:1183> Error: 1002 Unable to bind socket. System errno: (98)
'. ', ErrorCode='-1'
[tbricks@lsp7037c Ema]$ uname -a
Linux lsp7037c.XXXX.se 3.10.0-1160.53.1.el7.x86_64 #1 SMP Thu Dec 16 10:19:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

We are using libema-2.0.0.so

ema-apiinteractive-provider
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
47.2k 110 44 60

@Martin Hallerdal

I found that this issue has been fixed in RTSDK 2.0.6.L1.

EMA C++ 3.6.6.L1 Issues Resolved

  • [RTSDK-1486] - Fix to EMA examples to account for MapEntry key which can be Buffer, Ascii or Rmtes
  • [RTSDK-6099] - Port is not released after destroying OMMProvider [GitHub #192]
  • [RTSDK-6125] - Ensure that LibcurlName can be specified via programmatic config (removed from file config)
  • [RTSDK-6150] - EMA_Config Guide shows duplicate definitions: NumberOfLogFiles, Filename, etc
  • [RTSDK-6168] - InitializationTimeout does not take effect via programmatic config [GitHub #196]
  • [RTSDK-6302] - EMAC++'s default Login request does not have the correct position on Windows
  • [RTSDK-6290] - Cons470 Segmentation fault when connect to server doesn't support warmstandby and Ctrl+C
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
29k 33 11 15

Hello @Martin Hallerdal ,

To verify, I have tried running your code as is. I am running with the latest RTSDK 2.0.4.

The only modification was config

 Gateway() : m_provider(OmmIProviderConfig().port("14002"), *this) {}

My result:

Creating gateway...
~Gateway()
Creating gateway...
~Gateway()
Creating gateway...
~Gateway()
Creating gateway...
~Gateway()
Creating gateway...
~Gateway()

C:\Real-Time-SDK-20220103\Cpp-C\Ema\Executables\WIN_64_VS142\Debug_MDd\IProv100.exe (process 43768) exited with code 0.
Press any key to close this window . . .

-so I did not reproduce this issue.

I have also looped the simple provider example IProvider 100 that came with SDK:

int main()
{
for (int j = 0; j < 5; j++) {
cout << endl << "Iteration: "<< j << " coming in..." << endl;
try
{
AppClient appClient;

OmmProvider provider(OmmIProviderConfig().port("14002"), appClient);

while (itemHandle == 0) sleep(1000);

for (Int32 i = 0; i < 10/*60*/; i++)
{
provider.submit(UpdateMsg().payload(FieldList().
addReal(22, 3391 + i, OmmReal::ExponentNeg2Enum).
addReal(30, 10 + i, OmmReal::Exponent0Enum).
complete()), itemHandle);

sleep(1000);
}
}
catch (const OmmException& excp)
{
cout << excp << endl;
itemHandle = 0;
}
cout << endl << "Iteration: " << j << " coming out..." << endl;
}
return 0;
}

Connecting Consumer100 example to it and consuming the test data. I did not reproduce the port bind issue either.

I have looked through RTSDK 2.0.4 changelog for relevant fixes, the only similar fix:

" [RTSDK-4249] - Provider and VAProvider cannot bind port if setting compressionType to LZ4 when setting subprotocol"

is listed as fixed in version 1.5.1, prior to version 2.0.0, you should have it.


This may be local to the environment? Another process could be binding to the same port?

I would try to retest with a different, unused port, and if possible, rebuild with the latest RTSDK 2.0.4, to make sure you benefit from all the latest fixes and improvements.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
29k 33 11 15

Hello @Martin Hallerdal ,

Consequently, I have had a chance to run the same tests, with RTSDK 2.0.0 and 2.0.4 EMA on Linux, and I see what appears to be the same sys error "Unable to bind socket".

I have referred your report to RTSDK development team to verify:

https://github.com/Refinitiv/Real-Time-SDK/issues/192

and will update in this thread once we have further information to share

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Many thanks Zoya