Use UUID to ensure client_id uniqueness #713
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Public API Changes
None
Description
This is a minor update to the
client_id
that is used in the websocket handler to use a UUID instead of an incremented integer. The UUID was already being generated inwebsocket_handler.py
for each client connection but it was not being passed to the RosbridgeProtocol constructor for some reason.This is an improvement because the protocol expects the client ID to be unique and a UUID has better guarantees than an incremented count. See the code comment in the
__init__
method ofrosbridge_library/src/rosbridge_library/protocol.py
stating the importance of client ID uniqueness.This is also an improvement because the client ID will be unique across multiple instances of the websocket handler and also client IDs will not repeat with restarted servers. This can help with logging to be able to trace down interactions with a specific client connection.
The client ID will now be a UUID instead of an integer. See an example log message:
I made this change as part of #676 but since that was closed I am making a smaller PR with only this change.