Skip to content

Commit 6c8af87

Browse files
gguusskurtisvg
authored andcommitted
Device sample updates (#1035)
* Adds exponential backoff to MQTT * Updates to v1 base URI and ensures TLSv1.2 is used.
1 parent 3a8c271 commit 6c8af87

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

iot/api-client/manager/src/main/java/com/example/cloud/iot/examples/HttpExampleOptions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public class HttpExampleOptions {
3333
String cloudRegion = "us-central1";
3434
int numMessages = 100;
3535
int tokenExpMins = 20;
36-
String httpBridgeAddress = "https://cloudiot-device.googleapis.com";
37-
String apiVersion = "v1beta1";
36+
String httpBridgeAddress = "https://cloudiotdevice.googleapis.com";
37+
String apiVersion = "v1";
3838
String messageType = "event";
3939

4040
/** Construct an HttpExampleOptions class from command line flags. */

iot/api-client/manager/src/main/java/com/example/cloud/iot/examples/MqttExample.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import java.nio.file.Paths;
2525
import java.security.KeyFactory;
2626
import java.security.spec.PKCS8EncodedKeySpec;
27+
import java.util.Properties;
28+
2729
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
2830
import org.eclipse.paho.client.mqttv3.MqttCallback;
2931
import org.eclipse.paho.client.mqttv3.MqttClient;
@@ -158,6 +160,10 @@ public static void main(String[] args) throws Exception {
158160
// connection to your device.
159161
connectOptions.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
160162

163+
Properties sslProps = new Properties();
164+
sslProps.setProperty("com.ibm.ssl.protocol", "TLSv1.2");
165+
connectOptions.setSSLProperties(sslProps);
166+
161167
// With Google Cloud IoT Core, the username field is ignored, however it must be set for the
162168
// Paho client library to send the password field. The password field is used to transmit a JWT
163169
// to authorize the device.

0 commit comments

Comments
 (0)