Skip to content

Commit d16ec67

Browse files
committed
fix connection lost problem
1 parent 02afe72 commit d16ec67

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

arduino-iot-client-mqtt/arduino-iot-client-mqtt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class ArduinoClientMqtt {
9090
return reject(new Error('connection failed: you need to provide a valid token'));
9191
}
9292

93-
const userid = jws.decode(options.token).payload["http://arduino.cc/user_id"];
93+
const userid = jws.decode(options.token).payload["http://arduino.cc/id"];
9494
const clientID = `${userid}:${new Date().getTime()}`;
9595
const connectionOpts = {
9696
clientId: clientID,

utils/arduino-connection-manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ async function getToken(connectionConfig) {
6060
rawdata = await request(accessTokenUri, options);
6161
data = JSON.parse(rawdata.body);
6262
var token = data.access_token;
63-
expires_in = data.expires_in;
63+
expires_in = data.expires_in * 0.8; // needed to change the token before it expires
6464
if (token !== undefined) {
6565
return { token: token, expires_in: expires_in };
6666
}

0 commit comments

Comments
 (0)