因为云平台删除设备并重新创建,所以不论是一机一密,还是一型一密,都不支持这样的“骚操作”——因为保存的key已经变更,所以无法连接到阿里云的。
这种特殊情况,开发者需要自己修改代码,如果连接错误,应当重启后重新获取key。
部分trace如下:
[2018-09-15 09:58:47.751]: [I]-[ril.sendat]AT+SSLCREATE=2,"a1BRjIHrcmZ.iot-as-mqtt.cn-shanghai.aliyuncs.com:1883",1
[2018-09-15 09:58:47.791]: [I]-[ril.proatc]
[2018-09-15 09:58:47.798]: [I]-[ril.proatc]SSL&2,CREATE OK
[2018-09-15 09:58:47.801]: [I]-[ril.defrsp]AT+SSLCREATE=2,"a1BRjIHrcmZ.iot-as-mqtt.cn-shanghai.aliyuncs.com:1883",1trueSSL&2,CREATE OKnil
[2018-09-15 09:58:47.804]: [I]-[ril.sendat]AT+SSLCONNECT=2
[2018-09-15 09:58:47.807]: [I]-[ril.proatc]
[2018-09-15 09:58:47.812]: [I]-[ril.proatc]OK
[2018-09-15 09:58:49.059]: [I]-[testUpdate.version]1.0.1
[2018-09-15 09:58:51.520]: [I]-[ril.proatc]
[2018-09-15 09:58:51.527]: [I]-[ril.proatc]SSL&2,CONNECT OK
[2018-09-15 09:58:51.582]: [D]-[mqtt.client:write]105D00044D51545404C200F0000F383639333030303335373238393138001E64653933384C41306D4257376377426F576F7950
[2018-09-15 09:58:51.591]: [I]-[ril.sendat]AT+SSLSEND=2,95
[2018-09-15 09:58:51.606]: [I]-[ril.proatc]>
[2018-09-15 09:58:51.610]: [I]-[ril.procatc.send]first 200 bytes]
[2018-09-15 09:58:52.067]: [I]-[ril.proatc]
[2018-09-15 09:58:52.070]: [I]-[ril.proatc]SSL&2,SEND OK
[2018-09-15 09:58:52.148]: [I]-[ril.proatc]
[2018-09-15 09:58:52.151]: [I]-[ril.proatc]SSL&2,CLOSED
[2018-09-15 09:58:52.154]: [I]-[mqtt.client:connect]connack error-1
[2018-09-15 09:58:52.157]: [I]-[ril.sendat]AT+SSLDESTROY=2
[2018-09-15 09:58:52.171]: [I]-[ril.proatc]
[2018-09-15 09:58:52.176]: [I]-[ril.proatc]+SSL RECEIVE,2,4:
[2018-09-15 09:58:52.182]: [I]-[ril.proatc]
[2018-09-15 09:58:52.195]: [I]-[ril.proatc]
[2018-09-15 09:58:52.202]: [I]-[ril.proatc]SSL&2,DESTROY OK
[2018-09-15 09:58:54.216]: [I]-[ril.sendat]AT+SSLCREATE=1,"a1BRjIHrcmZ.iot-as-mqtt.cn-shanghai.aliyuncs.com:1883",1
[2018-09-15 09:58:54.276]: [I]-[ril.proatc]
[2018-09-15 09:58:54.278]: [I]-[ril.proatc]SSL&1,CREATE OK
[2018-09-15 09:58:54.280]: [I]-[ril.defrsp]AT+SSLCREATE=1,"a1BRjIHrcmZ.iot-as-mqtt.cn-shanghai.aliyuncs.com:1883",1trueSSL&1,CREATE OKnil
[2018-09-15 09:58:54.284]: [I]-[ril.sendat]AT+SSLCONNECT=1
[2018-09-15 09:58:54.285]: [I]-[ril.proatc]
[2018-09-15 09:58:54.287]: [I]-[ril.proatc]OK
[2018-09-15 09:58:55.898]:
[2018-09-15 09:58:57.579]: [I]-[ril.proatc]
[2018-09-15 09:58:57.582]: [I]-[ril.proatc]SSL&1,CONNECT OK
[2018-09-15 09:58:57.622]: [D]-[mqtt.client:write]105D00044D51545404C200F0000F383639333030303335373238393138001E64653933384C41306D4257376377426F576F7950
[2018-09-15 09:58:57.624]: [I]-[ril.sendat]AT+SSLSEND=1,95
[2018-09-15 09:58:57.642]: [I]-[ril.proatc]>
[2018-09-15 09:58:57.644]: [I]-[ril.procatc.send]first 200 bytes]
[2018-09-15 09:58:58.064]: [I]-[ril.proatc]
[2018-09-15 09:58:58.068]: [I]-[ril.proatc]SSL&1,SEND OK
[2018-09-15 09:58:58.146]: [I]-[ril.proatc]
[2018-09-15 09:58:58.149]: [I]-[ril.proatc]SSL&1,CLOSED
[2018-09-15 09:58:58.152]: [I]-[mqtt.client:connect]connack error-1
[2018-09-15 09:58:58.167]: [I]-[ril.sendat]AT+SSLDESTROY=1
[2018-09-15 09:58:58.207]: [I]-[ril.proatc]
[2018-09-15 09:58:58.208]: [I]-[ril.proatc]+SSL RECEIVE,1,4:
[2018-09-15 09:58:58.209]: [I]-[ril.proatc]
[2018-09-15 09:58:58.228]: [I]-[ril.proatc]
[2018-09-15 09:58:58.230]: [I]-[ril.proatc]SSL&1,DESTROY OK
[2018-09-15 09:59:00.270]: [I]-[ril.sendat]AT+SSLCREATE=0,"a1BRjIHrcmZ.iot-as-mqtt.cn-shanghai.aliyuncs.com:1883",1
[2018-09-15 09:59:00.310]: [I]-[ril.proatc]
[2018-09-15 09:59:00.315]: [I]-[ril.proatc]SSL&0,CREATE OK
[2018-09-15 09:59:00.318]: [I]-[ril.defrsp]AT+SSLCREATE=0,"a1BRjIHrcmZ.iot-as-mqtt.cn-shanghai.aliyuncs.com:1883",1trueSSL&0,CREATE OKnil
[2018-09-15 09:59:00.321]: [I]-[ril.sendat]AT+SSLCONNECT=0
[2018-09-15 09:59:00.326]: [I]-[ril.proatc]
[2018-09-15 09:59:00.329]: [I]-[ril.proatc]OK
[2018-09-15 09:59:03.680]: [I]-[ril.proatc]
[2018-09-15 09:59:03.682]: [I]-[ril.proatc]SSL&0,CONNECT OK
[2018-09-15 09:59:03.741]: [D]-[mqtt.client:write]105D00044D51545404C200F0000F383639333030303335373238393138001E64653933384C41306D4257376377426F576F7950
[2018-09-15 09:59:03.742]: [I]-[ril.sendat]AT+SSLSEND=0,95
[2018-09-15 09:59:03.783]: [I]-[ril.proatc]>
[2018-09-15 09:59:03.785]: [I]-[ril.procatc.send]first 200 bytes]
[2018-09-15 09:59:04.064]: [I]-[testUpdate.version]1.0.1
[2018-09-15 09:59:04.304]: [I]-[ril.proatc]
[2018-09-15 09:59:04.305]: [I]-[ril.proatc]SSL&0,SEND OK
[2018-09-15 09:59:04.384]: [I]-[ril.proatc]
[2018-09-15 09:59:04.386]: [I]-[ril.proatc]SSL&0,CLOSED
[2018-09-15 09:59:04.387]: [I]-[mqtt.client:connect]connack error-1
[2018-09-15 09:59:04.389]: [I]-[ril.sendat]AT+SSLDESTROY=0
[2018-09-15 09:59:04.406]: [I]-[ril.proatc]
[2018-09-15 09:59:04.410]: [I]-[ril.proatc]+SSL RECEIVE,0,4:
[2018-09-15 09:59:04.411]: [I]-[ril.proatc]
[2018-09-15 09:59:04.429]: [I]-[ril.proatc]
[2018-09-15 09:59:04.432]: [I]-[ril.proatc]SSL&0,DESTROY OK
我们这边是这样操作的,本来已经成功连接,并将数据上传至平台数据了,但此时我们的后台管理人员将此设备进行了删除并重新创建,后面就出现“[mqtt.client:connect]connack error-1”,上面的trace为连接失败的trace。请问这是不是和重连有关系,应该怎么解决重连失败的问题?
因为云平台删除设备并重新创建,所以不论是一机一密,还是一型一密,都不支持这样的“骚操作”——因为保存的key已经变更,所以无法连接到阿里云的。
这种特殊情况,开发者需要自己修改代码,如果连接错误,应当重启后重新获取key。
如果觉得我的回答对您有用,请随意打赏。你的支持将鼓励我继续创作!