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