mqtt5 multi-initialization workaround for Lambda #448
-
Hello, We are trying to use We have created a file that makes a singleton out of an mqtt5 client: const cfg = {
endpoint: '213421342134-ats.iot.2341234.amazonaws.com',
key: fs.readFileSync(path.resolve(__dirname, 'slaven-osx-thing-private.pem.key'), 'utf8'),
cert: fs.readFileSync(path.resolve(__dirname, 'slaven-osx-thing-certificate.pem.crt'), 'utf8')
}
const builder = iot.AwsIotMqtt5ClientConfigBuilder.newDirectMqttBuilderWithMtlsFromMemory(cfg.endpoint, cfg.cert, cfg.key)
const config: mqtt5.Mqtt5ClientConfig = builder.build()
export const client = new mqtt5.Mqtt5Client(config) And then we import it into a Lambda handler: export const handler = async () => {
const connectionSuccess = once(client, 'connectionSuccess')
client.start()
await connectionSuccess
console.log('🟢Connected to AWS IoT')
const stopped = once(client, 'stopped')
client.stop()
await stopped
console.log('Stopped client')
client.close()
console.log('Closed client')
....
} The first time we call the Lambda everything goes as expected. The client connects, then disconnects
Does anyone have any ideas on a workaround? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Multi-initialization was resolved in https://github.com/awslabs/aws-crt-nodejs/releases/tag/v1.15.17 |
Beta Was this translation helpful? Give feedback.
Multi-initialization was resolved in https://github.com/awslabs/aws-crt-nodejs/releases/tag/v1.15.17
A related issue where node would crash when unloading the CRT's native code from a worker thread was resolved in https://github.com/awslabs/aws-crt-nodejs/releases/tag/v1.15.19