jimmyn / aws-mqtt-client

AWS Websocket Pub/Sub client
Other
155 stars 17 forks source link

sessionToken #4

Open questsin opened 7 years ago

questsin commented 7 years ago

where do you get the AWS session token from?

just4give commented 7 years ago

AWS.config.credentials.sessionToken

Rajat07101994 commented 7 years ago

how we get aws config credential session token

Rajat07101994 commented 7 years ago

my mqtt script is running but it not suscribe any topic of aws iot

const AWS = require('aws-sdk') const AWSMqtt = require('aws-mqtt') const WebSocket = require('ws')

AWS.config

AWS.config.region = 'us-east-1' // AWS.config.credentials = './cert/credentials'

debugger; const client = AWSMqtt.connect({ WebSocket: WebSocket, region: AWS.config.region, credentials: AWS.config.credentials, endpoint: 'a1qs749674of68.iot', // NOTE: get this value with aws iot describe-endpoint clientId: 'iotconsole-1484568658306-179514', // clientId to register with MQTT broker. Need to be unique per client },(error,connect)=>{ if(error) { console.log("error" +error); } if(connect) { console.log("data is connected",connect); } });

client.on('connect', () => { client.subscribe('/myTopic')

console.log("Topic is suscribed"); client.publish('/myTopic','i am here') }); client.on('message', (topic, message) => { console.log(topic, message) });

client.on('offline', () => { client.subscribe('/myTopic/off') client.publish('/myTopic/off','i am gone') }); but my script is connect and then disconnect it neither suscribe the topic nor it show an error message that error in correction