code-iai / ROSIntegration

Unreal Engine Plugin to enable ROS Support
MIT License
411 stars 133 forks source link

Fix to avoid bug when reading subscription message header #179

Closed PetterVMC closed 1 year ago

PetterVMC commented 2 years ago

There was a problem that in some environments, after a random time of play (usually a minute or so) the subscription message processing suddenly failed and could not recover.

After investigation, it turns out that this happened if the message header (the first 4 bytes for the message length) arrived in multiple packets, i.e. it could not be read by only one _sock->Recv() instruction. In this case the error message "bytes_read is not 4 in bson_state_read_length==true." would display and from there on no further message processing can be done.

Fixed this by allowing reading of the header multiple times until all 4 bytes have been read.

Sanic commented 1 year ago

Thanks for the PR!