mqttjs / MQTT.js

The MQTT client for Node.js and the browser
Other
8.54k stars 1.41k forks source link

Unacceptable protocol version mqtt v3 #652

Closed willin closed 1 year ago

willin commented 7 years ago
events.js:182
      throw er; // Unhandled 'error' event
      ^

Error: Connection refused: Unacceptable protocol version
    at MqttClient._handleConnack (/Users/willin/Desktop/未命名文件夹/node_modules/mqtt/lib/client.js:791:15)
    at MqttClient._handlePacket (/Users/willin/Desktop/未命名文件夹/node_modules/mqtt/lib/client.js:307:12)
    at process (/Users/willin/Desktop/未命名文件夹/node_modules/mqtt/lib/client.js:249:12)
    at Writable.writable._write (/Users/willin/Desktop/未命名文件夹/node_modules/mqtt/lib/client.js:259:5)
    at doWrite (/Users/willin/Desktop/未命名文件夹/node_modules/readable-stream/lib/_stream_writable.js:406:64)
    at writeOrBuffer (/Users/willin/Desktop/未命名文件夹/node_modules/readable-stream/lib/_stream_writable.js:395:5)
    at Writable.write (/Users/willin/Desktop/未命名文件夹/node_modules/readable-stream/lib/_stream_writable.js:322:11)
    at TLSSocket.ondata (_stream_readable.js:628:20)
    at emitOne (events.js:115:13)
    at TLSSocket.emit (events.js:210:7)
const client = mqtt.connect('ssl://xxx.azure-devices.cn:8883', {
  username: 'xxx',
  password: 'xxx',
  clientId: 'xxx',
  protocolId: 'MQTT',
  protocolVersion: 3,
  will: {
    topic: 'xxx',
    payload: 'disconnected will',
    qos: 1,
    retain: true
  }
});
mcollina commented 7 years ago

I think protocolVersion should be 4 for Azure.

willin commented 7 years ago
Unhandled rejection AmqpError
    at Connection.<anonymous> (/Users/willin/Documents/dwing/AirHub/node_modules/amqp10/lib/amqp_client.js:182:23)
    at emitOne (events.js:115:13)
    at Connection.emit (events.js:210:7)
    at Connection._terminate (/Users/willin/Documents/dwing/AirHub/node_modules/amqp10/lib/connection.js:551:8)
    at Connection._processError (/Users/willin/Documents/dwing/AirHub/node_modules/amqp10/lib/connection.js:351:8)
    at Object.errorHandler (/Users/willin/Documents/dwing/AirHub/node_modules/amqp10/lib/connection.js:282:43)
    at Object.event (/Users/willin/Documents/dwing/AirHub/node_modules/stately.js/Stately.js:203:67)
    at Object.event (/Users/willin/Documents/dwing/AirHub/node_modules/stately.js/Stately.js:190:52)
    at Object.event (/Users/willin/Documents/dwing/AirHub/node_modules/stately.js/Stately.js:190:52)
    at Object.event (/Users/willin/Documents/dwing/AirHub/node_modules/stately.js/Stately.js:190:52)
    at Object.event (/Users/willin/Documents/dwing/AirHub/node_modules/stately.js/Stately.js:190:52)
    at Object.event (/Users/willin/Documents/dwing/AirHub/node_modules/stately.js/Stately.js:190:52)
    at Object.event (/Users/willin/Documents/dwing/AirHub/node_modules/stately.js/Stately.js:190:52)
    at Object.event (/Users/willin/Documents/dwing/AirHub/node_modules/stately.js/Stately.js:190:52)
    at Object.event (/Users/willin/Documents/dwing/AirHub/node_modules/stately.js/Stately.js:190:52)
    at Object.event (/Users/willin/Documents/dwing/AirHub/node_modules/stately.js/Stately.js:190:52)

Unhandled rejection AmqpError
    at Connection.<anonymous> (/Users/willin/Documents/dwing/AirHub/node_modules/amqp10/lib/amqp_client.js:182:23)
    at emitOne (events.js:115:13)
    at Connection.emit (events.js:210:7)
    at Connection._terminate (/Users/willin/Documents/dwing/AirHub/node_modules/amqp10/lib/connection.js:551:8)
    at Connection._processError (/Users/willin/Documents/dwing/AirHub/node_modules/amqp10/lib/connection.js:351:8)
    at Object.errorHandler (/Users/willin/Documents/dwing/AirHub/node_modules/amqp10/lib/connection.js:282:43)
    at Object.event (/Users/willin/Documents/dwing/AirHub/node_modules/stately.js/Stately.js:203:67)
    at Object.event (/Users/willin/Documents/dwing/AirHub/node_modules/stately.js/Stately.js:190:52)
    at Object.event (/Users/willin/Documents/dwing/AirHub/node_modules/stately.js/Stately.js:190:52)
    at Object.event (/Users/willin/Documents/dwing/AirHub/node_modules/stately.js/Stately.js:190:52)
    at Object.event (/Users/willin/Documents/dwing/AirHub/node_modules/stately.js/Stately.js:190:52)
    at Object.event (/Users/willin/Documents/dwing/AirHub/node_modules/stately.js/Stately.js:190:52)
    at Object.event (/Users/willin/Documents/dwing/AirHub/node_modules/stately.js/Stately.js:190:52)
    at Object.event (/Users/willin/Documents/dwing/AirHub/node_modules/stately.js/Stately.js:190:52)
    at Object.event (/Users/willin/Documents/dwing/AirHub/node_modules/stately.js/Stately.js:190:52)
    at Object.event (/Users/willin/Documents/dwing/AirHub/node_modules/stately.js/Stately.js:190:52)

when 4

mcollina commented 7 years ago

Nothing in those stacktrace shows MQTT.js, or am I reading them wrong?

wijamw commented 7 years ago

I have same error but different description events.js:182 throw er; // Unhandled 'error' event ^

Error: read ECONNRESET at exports._errnoException (util.js:1022:11) at TLSWrap.onread (net.js:610:25)

This is my code from example that have been provided. Then I changed it to localhost.

var mqtt = require('mqtt') var client = mqtt.connect('mqtts://127.0.0.1:1883') client.on('connect', function () { client.subscribe('presence') client.publish('presence', 'Hello mqtt') }) client.on('message', function (topic, message) { // message is Buffer console.log(message.toString()) client.end() })

github-actions[bot] commented 1 year ago

This is an automated message to let you know that this issue has gone 365 days without any activity. In order to ensure that we work on issues that still matter, this issue will be closed in 14 days.

If this issue is still important, you can simply comment with a "bump" to keep it open.

Thank you for your contribution.

github-actions[bot] commented 1 year ago

This issue was automatically closed due to inactivity.