I have aws lambda function that generates IOT websocket URL as below.
const v4 = require('aws-signature-v4');
const crypto = require('crypto');
const WSSURL = v4.createPresignedURL(
'GET',
process.env.IOT_ENDPOINT_HOST.toLowerCase(),
'/mqtt',
'iotdevicegateway',
crypto.createHash('sha256').update('', 'utf8').digest('hex'),
{
'key': process.env.IOT_ACCESS_KEY,
'secret': process.env.IOT_SECRET_KEY,
'protocol': 'wss',
'region': process.env.IOT_AWS_REGION,
}
);
and I have mqttjs at client side that use this url and try to connect web socket as following.
var options = {
will : {
topic : LAST_WILL_TOPIC,
payload: getMessageString(wss_userId, wss_email, wss_userType, {})
},
clientId: wss_userType + '||' + wss_userId
};
wssClient = mqtt.connect(WSSURL, options);
This code was working perfect before few months but now connection doesn't initiate and gives following error
failed: Error during WebSocket handshake: Unexpected response code: 403