Skip to content

Message can be lost if the sender exits right after sending it #201

Open
@enrico-samknows

Description

@enrico-samknows

Hello, I'm trying to write a program which publishes a single message, then quits.
By using strace, I can see a new child process is spawned, which does the sending part.
When I destroy the pub_socket the message is not sent yet. I also do io_context.run() and when it returns the message is not sent yet.
I also tried to let io_context go out of scope, but it doesn't force the message to be sent.
The only thing working for me is adding a sleep_for in the main thread. Then I see the message is sent with 100% success rate.

Is there a better way to "flush" the socket or to perform a "controlled close", so when it returns I can be 100% sure the message has been sent? I'm using an IPC transport, but I guess it's a common issue to all transports.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions