You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Checkout the iche033/pub_sub_no_msg branch and build the examples
In one terminal, run the subscriber executable
In another terminal, run test_publisher - you should see Enter any key to publish message printed is the console
Hit enter in the test_publisher terminal to publish a message.
Publisher fails due to no connections(issue 1)
Hit enter again in the test_publisher terminal. This time publish succeeds and a message in printed in the subscriber terminal.
Restart subscriber, e.g. Ctrl+C and run ./subscriber again
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.
The text was updated successfully, but these errors were encountered:
Environment
gz-transport14
branchDescription
Steps to reproduce
I have added an example
test_publisher
executable in theexample
directory in the iche033/pub_sub_no_msg branch to demonstrate the issue:iche033/pub_sub_no_msg
branch and build the examplessubscriber
executabletest_publisher
- you should seeEnter any key to publish message
printed is the consoletest_publisher
terminal to publish a message.test_publisher
terminal. This time publish succeeds and a message in printed in thesubscriber
terminal.subscriber
, e.g. Ctrl+C and run./subscriber
againtest_publisher
terminal and hit any key to publish a messagesubscriber
(issue 2)I have highlighted the issues in bold above.
HasConnections
return trueHasConnections
call actually returnedtrue
so it attempts to publish a message. ThePublish
call also returnedtrue
so it thinks that the message is published successfully.Note that if I add a
std::this_thread::sleep_for(std::chrono::milliseconds(1000)
right afternode.Advertise
intest_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.The text was updated successfully, but these errors were encountered: