Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1cad11a

Browse filesBrowse files
CarlosMendoncagguuss
authored andcommitted
Possible fix to message encoding issue (GoogleCloudPlatform#1990)
It throws an exception when trying to parse to JSON. Could use a second opinion on this solution. Original Codelab instructions available [here](https://codelabs.developers.google.com/codelabs/cloud-iot-core-overview/index.html?index=..%2F..index#0).
1 parent c630c60 commit 1cad11a
Copy full SHA for 1cad11a

File tree

Expand file treeCollapse file tree

2 files changed

+2
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+2
-2
lines changed

‎iot/api-client/end_to_end_example/cloudiot_pubsub_example_mqtt_device.py

Copy file name to clipboardExpand all lines: iot/api-client/end_to_end_example/cloudiot_pubsub_example_mqtt_device.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def on_subscribe(self, unused_client, unused_userdata, unused_mid,
122122

123123
def on_message(self, unused_client, unused_userdata, message):
124124
"""Callback when the device receives a message on a subscription."""
125-
payload = message.payload
125+
payload = message.payload.decode('utf-8')
126126
print('Received message \'{}\' on topic \'{}\' with Qos {}'.format(
127127
payload, message.topic, str(message.qos)))
128128

‎iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py

Copy file name to clipboardExpand all lines: iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def callback(message):
152152
subscribed topic.
153153
"""
154154
try:
155-
data = json.loads(message.data)
155+
data = json.loads(message.data.decode('utf-8'))
156156
except ValueError as e:
157157
print('Loading Payload ({}) threw an Exception: {}.'.format(
158158
message.data, e))

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.