esp32,基于阿里云平台,配置实现Node.js SDK接入示例出现description: ‘Failed to authenticate: 4‘ BUG

项目场景:

需要esp32板子一块,一个wifi热点,最好是自己手机的


问题描述

当你配置好阿里云官方文档所需要的信息后,出现报错:description: 'Failed to authenticate: 4'

node:events:491
      throw er; // Unhandled 'error' event
      ^
ConnectionError: Failed to authenticate: 4
    at Connection._handle_error (C:\Users\晨\Desktop\esp32test\node_modules\.store\rhea@3.0.2\node_modules\rhea\lib\connection.js:479:36)
    at Connection.sasl_failed (C:\Users\晨\Desktop\esp32test\node_modules\.store\rhea@3.0.2\node_modules\rhea\lib\connection.js:454:10)
    at SaslClient.on_sasl_outcome (C:\Users\晨\Desktop\esp32test\node_modules\.store\rhea@3.0.2\node_modules\rhea\lib\sasl.js:314:25)
    at c.dispatch (C:\Users\晨\Desktop\esp32test\node_modules\.store\rhea@3.0.2\node_modules\rhea\lib\types.js:948:33)
    at Transport.read (C:\Users\晨\Desktop\esp32test\node_modules\.store\rhea@3.0.2\node_modules\rhea\lib\transport.js:117:36)
    at SaslClient.read (C:\Users\晨\Desktop\esp32test\node_modules\.store\rhea@3.0.2\node_modules\rhea\lib\sasl.js:346:31)
    at Connection.input (C:\Users\晨\Desktop\esp32test\node_modules\.store\rhea@3.0.2\node_modules\rhea\lib\connection.js:567:37)
    at TLSSocket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
Emitted 'error' event on Container instance at:
    at Container.dispatch (C:\Users\晨\Desktop\esp32test\node_modules\.store\rhea@3.0.2\node_modules\rhea\lib\container.js:41:33)
    at Connection.dispatch (C:\Users\晨\Desktop\esp32test\node_modules\.store\rhea@3.0.2\node_modules\rhea\lib\connection.js:261:40)
    at Connection.input (C:\Users\晨\Desktop\esp32test\node_modules\.store\rhea@3.0.2\node_modules\rhea\lib\connection.js:593:18)
    at TLSSocket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at TLSSocket.Readable.push (node:internal/streams/readable:228:10)
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23) {
  condition: 'amqp:internal-error',
  description: 'Failed to authenticate: 4'
}

原因分析:

const container = require('rhea'); const crypto = require('crypto'); //创建Connection。 var connection = container.connect({ //接入域名,请参见AMQP客户端接入说明文档。 'host': '${YourHost}', 'port': 5671, 'transport':'tls', 'reconnect':true, 'idle_time_out':60000, //userName组装方法,请参见AMQP客户端接入说明文档。 'username':'${YourClientId}|authMode=aksign,signMethod=hmacsha1,timestamp=1573489088171,authId=${YourAccessKeyId},iotInstanceId=${YourIotInstanceId},consumerGroupId=${YourConsumerGroupId}|', //计算签名,password组装方法,请参见AMQP客户端接入说明文档。 'password': hmacSha1('${YourAccessKeySecret}', 'authId=${YourAccessKeyId}&timestamp=1573489088171'), });

你的如上信息表单配置错误,请配置的时候仔细按照官方文档指示配置
官方文档:Node.js SDK接入示例 (aliyun.com)


解决方案:

我遇到的问题是因为YourClientId 如果你是window11用户直接用直接的mac地址,你的格式是这样'00:DD:B6:BF:32:30,字符用:隔开的,但是就是因为这个原因,出现以上报错,你需要将  修改成 -

例如:

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值