@@ -94,7 +94,7 @@ public class MqttPublisher implements Publisher {
94
94
private static final Map <String , AtomicInteger > EVENT_SERIAL = new HashMap <>();
95
95
private static final String GCP_CLIENT_PREFIX = "projects/" ;
96
96
private static final Integer DEFAULT_MQTT_PORT = 8883 ;
97
- private static final long ATTACH_DELAY_MS = 1000 ;
97
+ private static final long RETRY_DELAY_MS = 1000 ;
98
98
private static final String LOCAL_MQTT_PREFIX = "/r/" ;
99
99
100
100
private final Semaphore connectionLock = new Semaphore (1 );
@@ -205,7 +205,7 @@ private void publishCore(String deviceId, String topicSuffix, Object data, Runna
205
205
debug (format ("Sending message to %s" , sendTopic ));
206
206
if (!sendMessage (deviceId , sendTopic , payload .getBytes ())) {
207
207
debug (format ("Queue message for retry %s %s" , topicSuffix , deviceId ));
208
- safeSleep (ATTACH_DELAY_MS );
208
+ safeSleep (RETRY_DELAY_MS );
209
209
if (isActive ()) {
210
210
publisherExecutor .submit (() -> publishCore (deviceId , topicSuffix , data , callback ));
211
211
}
@@ -321,20 +321,16 @@ private MqttClient newProxyClient(String deviceId) {
321
321
String gatewayId = getGatewayId ();
322
322
info (format ("Connecting device %s through gateway %s" , deviceId , gatewayId ));
323
323
final MqttClient mqttClient = getConnectedClient (gatewayId );
324
- long timeToWait = mqttClient .getTimeToWait ();
325
324
try {
326
325
startupLatchWait (connectionLatch , "gateway startup exchange" );
327
326
String topic = getMessageTopic (deviceId , MqttDevice .ATTACH_TOPIC );
328
327
info (format ("Publishing attach message %s" , topic ));
329
328
byte [] mqttMessage = EMPTY_STRING .getBytes (StandardCharsets .UTF_8 );
330
- mqttClient .setTimeToWait (ATTACH_DELAY_MS );
331
329
mqttClientPublish (mqttClient , topic , mqttMessage );
332
330
subscribeToUpdates (mqttClient , deviceId );
333
331
return mqttClient ;
334
332
} catch (Exception e ) {
335
333
throw new RuntimeException (format ("While binding client %s" , deviceId ), e );
336
- } finally {
337
- mqttClient .setTimeToWait (timeToWait );
338
334
}
339
335
}
340
336
0 commit comments