diff --git a/rosbridge_library/src/rosbridge_library/protocol.py b/rosbridge_library/src/rosbridge_library/protocol.py index 829685a70..caccfe110 100644 --- a/rosbridge_library/src/rosbridge_library/protocol.py +++ b/rosbridge_library/src/rosbridge_library/protocol.py @@ -127,7 +127,13 @@ def incoming(self, message_string=""): if self.bson_only_mode: self.buffer.extend(message_string) else: - self.buffer = self.buffer + str(message_string) + if isinstance(message_string, bytes): + try: + message_string = message_string.decode('utf-8') + except UnicodeDecodeError: + self.log("error", "Received binary message with invalid UTF-8 encoding") + return + self.buffer = self.buffer + message_string msg = None # take care of having multiple JSON-objects in receiving buffer