wpilibsuite / allwpilib

Official Repository of WPILibJ and WPILibC
https://wpilib.org/
Other
1.05k stars 611 forks source link

[ntcore] Failure to announce topics #5734

Closed jwbonner closed 11 months ago

jwbonner commented 11 months ago

Under particular circumstances, the NT server will send data to clients without a topic announcement. Based on my testing (using be939cb6366a5cafed1a62ce71b058525582a85d), the following seems to trigger the behavior somewhat consistently:

  1. The client subscribes to "topics only" for a large number of topics. In my testing I used >500 topics; it doesn't seem to appear for a small number of topics.
  2. Before a response is received from the server, the client subscribes to a topic or topics for data. The period must be short (my testing showed the issue on 0.02 but not 0.1).
  3. The server will send a wave of topic announcements in response to the "topics only" subscription, but this will exclude topic announcements for the data subscription.
  4. The server will start sending data for the data subscription without announcing the topics, meaning the topic IDs are unrecognized by the client.

Reversing the order of the subscriptions (data before topics only) seems to fix the issue. This also doesn't occur on the 2023 versions of NT. All of my testing has been connecting to a server running on localhost.

PeterJohnson commented 11 months ago

I've reproduced locally, looking into it. One key is for the periodic setting in the two subscribes to be different.