Server socket don't close on OmmProvider destroying.

I want to use an Interactive Provider as a server in my application. An object of OmmProvider is correctly created, configured as IProvider, binds socket and works well with all test Consumer apps, but when it comes to destroying an object and closing socket, it stays binded. So, next time I want to create a new OmmProvider object on this same port, it throws an exception (Error: 1002 Unable to bind socket. System errno: (98)) and can't bind second time. Using ServerSharedSocket=1 config option results in consumers just connecting to the old socket, ignoring a new one. Socket is closed well when the process is killed, but unfortunately, killing process is not an option, an app needs to be up and running all the time. In addition, there is a rsslCloseServer() method mentioned in Eta documentation. I guess this is what I need, but I don't see any way to call it on an Ema level. I cannot see any usages of it in the test examples of Ema either.

Could you please suggest how I can correctly close a OmmProvider's socket on Ema level without killing a process? Maybe there is some Server or Provider configuration option that I am missing?

Best Answer

Answers

  • @sviatoslav.bakaras

    I have modified the C++ IProv100 example in the RTSDK-2.0.1.L2.win.rrg (EMA 3.6.1.L2) package to creating a new OmmProvider after deleting the previous one. The code looks like this:

    int main()
    {
        try
        {
            AppClient appClient;
            while (true) {
                printf("Create OmmProvider\n");
                OmmProvider* provider = new OmmProvider(OmmIProviderConfig().port("14002"), appClient);
                itemHandle = 0;
                while (itemHandle == 0) sleep(1000);


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


                    sleep(1000);
                }
                printf("Delete OmmProvider\n");
                delete(provider);
                sleep(5000);
            };
            
        }
        catch ( const OmmException& excp )
        {
            cout << excp << endl;
        }
        
        return 0;
    }

    From my testing, the application can close and reopen TCP 14002 port properly.

    1625203700036.png

  • Hi @sviatoslav.bakaras

    On top of @jirapongse.phuriphanvichai answer, I also tested com.refinitiv.ema.examples.training.iprovider.series100.ex100_MP_Streaming on EMA Java.

    And it works fine as well.

    ahs1.png


  • @jirapongse.phuriphanvichai @chavalit.jintamalit , thank you for your investigations!

    I've also tried to reproduce this issue with a minimal code. Here it is, three simple steps, even without sending anything (modified IProv100):

    screenshot-from-2021-07-02-12-56-50.pngCreating a OmmProvider object, destroying it and creating a new one on the same port.

    Here is the output:

    Creating provider

    Deleting provider

    Creating provider one more time

    Exception Type='OmmInvalidUsageException', Text='Failed to initialize OmmServerBaseImpl (Unable to bind RSSL server).' Error Id='-1' Internal sysError='98' ..........

    Worth to mention, I'm running a RHEL7 (Red Hat Enterprise Linux Server release 7.4 (Maipo)) and using Clang 10.0.1 compiler. (Also tried with GCC 4.8.5, but it's all the same).

    I've also checked executable's syscalls with "strace" utility. There is a socket creation with "socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)", which returned "10", but there is no "close(10)" call after it to actually close it.

    Debugging Ema's code gave no results too. All methods, used in d-tor, returned success code, but still no close(..) called.