Closed wmmihaa closed 6 years ago
@wmmihaa Looks like 2 issues here:
In the interest of solving 2. I'd like to understand the setup that exposed the problem a little better:
[edit] It looks like what happened is that an error is emitted while the client is trying to disconnect. activating the debug traces (by setting the DEBUG
environment variable to azure*
or *
to be super verbose) might help (please scrub the logs for sensitive information before posting them here)
@wmmihaa I submitted #221 to prevent the exception you're seeing but I'm still worried about the second problem I describe in my first comment. If you come up with more information please let us know.
Did you want me to with DEBUG setting and send you the log?
Let me know if there is anything I can do...
@wmmihaa Yeah that'd be great - I'm not sure what error the amqp10 client emitted while we were disconnecting but it's suspicious: if we're only detaching/disconnecting, and we have callbacks on the detach/disconnect, why is it emitting errors? that's what i'd like to find out
@wmmihaa In order to repro i'd like to understand how you "disable the network adapter" on which OS - not clear to me if you're using WSL and Ubuntu on Windows, or Ubuntu and windows separately and both show the problem, and how you disable the network adapter (right click? ifup/down?)
@wmmihaa I'm going to go out on a limb and ask - does the same problem happens when you're not using the twin (ie not getting or updating it in any way, so that these links stay detached)?
@pierreca I am using WSL and Ubuntu on Windows + Windows 10, and They are not showing the same exception, although they both fail: WSL:
Using AMQP
AZURE IoT: Connected
AZURE IoT: Device twin is ready
AZURE IoT: Received new state
Event has been sent to Azure IoT Hub 1/(1)
/mnt/c/temp/deviceConnectivityTest/deviceConnectivityTest/node_modules/amqp10/lib/frames.js:64
stream.write(buffer, callback);
^
TypeError: Cannot read property 'write' of null
at Object.frames.writeFrame (/mnt/c/temp/deviceConnectivityTest/deviceConnectivityTest/node_modules/amqp10/lib/frames.js:64:9)
at Connection.sendFrame (/mnt/c/temp/deviceConnectivityTest/deviceConnectivityTest/node_modules/amqp10/lib/connection.js:329:10)
at SenderLink.Link._sendDetach (/mnt/c/temp/deviceConnectivityTest/deviceConnectivityTest/node_modules/amqp10/lib/link.js:228:27)
at Object.sendDetach (/mnt/c/temp/deviceConnectivityTest/deviceConnectivityTest/node_modules/amqp10/lib/link.js:34:14)
at Object.event [as sendDetach] (/mnt/c/temp/deviceConnectivityTest/deviceConnectivityTest/node_modules/stately.js/Stately.js:203:67)
at SenderLink.Link.detach (/mnt/c/temp/deviceConnectivityTest/deviceConnectivityTest/node_modules/amqp10/lib/link.js:129:11)
at constructor._onEnter (/mnt/c/temp/deviceConnectivityTest/deviceConnectivityTest/node_modules/azure-iot-amqp-base/lib/sender_link.js:204:47)
at constructor.transition (/mnt/c/temp/deviceConnectivityTest/deviceConnectivityTest/node_modules/machina/lib/machina.js:653:28)
at constructor.Fsm.(anonymous function) [as transition] (/mnt/c/temp/deviceConnectivityTest/deviceConnectivityTest/node_modules/machina/lib/machina.js:466:63)
at constructor.detach (/mnt/c/temp/deviceConnectivityTest/deviceConnectivityTest/node_modules/azure-iot-amqp-base/lib/sender_link.js:156:69)
at constructor.handle (/mnt/c/temp/deviceConnectivityTest/deviceConnectivityTest/node_modules/machina/lib/machina.js:613:25)
at constructor.Fsm.(anonymous function) [as handle] (/mnt/c/temp/deviceConnectivityTest/deviceConnectivityTest/node_modules/machina/lib/machina.js:466:63)
at SenderLink.detach (/mnt/c/temp/deviceConnectivityTest/deviceConnectivityTest/node_modules/azure-iot-amqp-base/lib/sender_link.js:225:19)
at /mnt/c/temp/deviceConnectivityTest/deviceConnectivityTest/node_modules/azure-iot-device-amqp/lib/amqp.js:417:50
at /mnt/c/temp/deviceConnectivityTest/deviceConnectivityTest/node_modules/async/dist/async.js:3866:24
at replenish (/mnt/c/temp/deviceConnectivityTest/deviceConnectivityTest/node_modules/async/dist/async.js:998:17)
wmmihaa@DESKTOP-6PS46DD:/mnt/c/temp/deviceConnectivityTest/deviceConnectivityTest$
And also, I'm just toggle of the WIFI. I can't run the script on the device without installing screen or a startup script (which I can't do on the ones at work), but if you find it important I can do that later today (CET) when I get home.
I'm going to go out on a limb and ask - does the same problem happens when you're not using the twin (ie not getting or updating it in any way, so that these links stay detached)?
@pierreca No the issue seams related to the twin. If I don't enable twin state, it all works:
λ node app.js amqp
Using AMQP
AZURE IoT: Connected
Event has been sent to Azure IoT Hub 1/(1)
Event has been sent to Azure IoT Hub 2/(2) // ==> Network disabled
Unable to send message to to Azure IoT Hub 3/(6)
Unable to send message to to Azure IoT Hub 4/(6)
Unable to send message to to Azure IoT Hub 5/(6)
Unable to send message to to Azure IoT Hub 6/(6)
AZURE IoT: Disconnected
Unable to send message to to Azure IoT Hub 7/(7)
Unable to send message to to Azure IoT Hub 8/(8)
Unable to send message to to Azure IoT Hub 9/(9)
Unable to send message to to Azure IoT Hub 10/(10)
Event has been sent to Azure IoT Hub 11/(11) // ==> Network enabled
Event has been sent to Azure IoT Hub 12/(12)
BTW... this works even better as I don't loose any messages, compared to MQTT where I lost a few messages. - Still not an option though, as I need the state :(
@wmmihaa FYI we released a new version of the packages that include a fix for the undefined callback (still smelling like there's an issue in the twin code though) https://github.com/Azure/azure-iot-sdk-node/releases/tag/2018-2-7
I ran the same scenario again, with stage enabled. No unhandled exception thrown and managed events triggered. However... the device does not seem to receive state updates after re-connecting.
@wmmihaa yes the Twin feature has recovery issues that we plan on fixing within the next couple of weeks. [edit] see my answer on #206
Looking forward to it... ;)
Context
Description of the issue:
Device client fails on disconnect using AMQP/AMQP-WS
Code sample exhibiting the issue:
Reproduce issue
Console log of the issue: