Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message published by a new publisher does not reach an existing subscriber #586

Open
iche033 opened this issue Mar 11, 2025 · 0 comments
Open
Labels
bug Something isn't working

Comments

@iche033
Copy link
Contributor

iche033 commented Mar 11, 2025

Environment

  • OS Version: Ubuntu 24.04
  • Source or binary build? source build, gz-transport14 branch

Description

  • Expected behavior: When a new publisher comes up, it fails to publish messages to an existing subscriber on the first try
  • Actual behavior: Publish always fails on the first try for different reasons, see steps to reproduce below

Steps to reproduce

I have added an example test_publisher executable in the example directory in the iche033/pub_sub_no_msg branch to demonstrate the issue:

  1. Checkout the iche033/pub_sub_no_msg branch and build the examples
  2. In one terminal, run the subscriber executable
  3. In another terminal, run test_publisher - you should see Enter any key to publish message printed is the console
  4. Hit enter in the test_publisher terminal to publish a message.
    • Publisher fails due to no connections (issue 1)
  5. Hit enter again in the test_publisher terminal. This time publish succeeds and a message in printed in the subscriber terminal.
  6. Restart subscriber, e.g. Ctrl+C and run ./subscriber again
  7. Go back to the test_publisher terminal and hit any key to publish a message
    • Publish call succeeds, however no messages are received by the subscriber (issue 2)

I have highlighted the issues in bold above.

  • issue 1:
    • my hypothesis is that discovery takes time so when the publisher comes up, it has not had time to be notified of all existing subscribers.
      • This is less of a problem as we can keep retrying until HasConnections return true
  • issue 2:
    • when the publisher comes up, the HasConnections call actually returned true so it attempts to publish a message. The Publish call also returned true so it thinks that the message is published successfully.
      • This is more of a problem as there is no indication that the message never reached the subscriber.

Note that if I add a std::this_thread::sleep_for(std::chrono::milliseconds(1000) right after node.Advertise in test_publisher.cc, everything works fine. Same thing if I just move the publisher out of the while loop (so that the publisher is alive for the whole duration), everything works as expected.

@iche033 iche033 added the bug Something isn't working label Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Inbox
Development

No branches or pull requests

1 participant