Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

node:events:356 throw err; // Unhandled 'error' event #52

Open
sednarb opened this issue May 14, 2021 · 2 comments
Open

node:events:356 throw err; // Unhandled 'error' event #52

sednarb opened this issue May 14, 2021 · 2 comments

Comments

@sednarb
Copy link

sednarb commented May 14, 2021

node.js version = v16.1.0
npm version = 7.13.0

When i start the program, the following error occurs:

Using IoT Hub connection string [HostName=BS-Hub.azure-devices.net;SharedAccessKeyName=service;SharedAccessKey=***=]
monitoring
Using event hub consumer group [monitoring]
Listening on 3000.
node:events:356
throw err; // Unhandled 'error' event
^

Error [ERR_UNHANDLED_ERROR]: Unhandled error. ({
_context: Error: Invalid handle 0
at Session._get_link (C:\Users\phili\Documents\Schule\BA\temp4\web-apps-node-iot-hub-data-visualization\node_modules\rhea\lib\session.js:724:15)
at Session.on_detach (C:\Users\phili\Documents\Schule\BA\temp4\web-apps-node-iot-hub-data-visualization\node_modules\rhea\lib\session.js:730:10)
at Connection. [as on_detach] (C:\Users\phili\Documents\Schule\BA\temp4\web-apps-node-iot-hub-data-visualization\node_modules\rhea\lib\connection.js:804:30)
at c.dispatch (C:\Users\phili\Documents\Schule\BA\temp4\web-apps-node-iot-hub-data-visualization\node_modules\rhea\lib\types.js:910:33)
at Transport.read (C:\Users\phili\Documents\Schule\BA\temp4\web-apps-node-iot-hub-data-visualization\node_modules\rhea\lib\transport.js:109:36)
at SaslClient.read (C:\Users\phili\Documents\Schule\BA\temp4\web-apps-node-iot-hub-data-visualization\node_modules\rhea\lib\sasl.js:328:26)
at Connection.input (C:\Users\phili\Documents\Schule\BA\temp4\web-apps-node-iot-hub-data-visualization\node_modules\rhea\lib\connection.js:538:35)
at TLSSocket.emit (node:events:365:28)
at addChunk (node:internal/streams/readable:314:12)
at readableAddChunk (node:internal/streams/readable:289:9),
.......

Does anyone know the problem?

@JohnLempkowski
Copy link

I believe I have this problem too. My call trace is the same save for some fuzziness of the line numbers care of the version difference.
node v10.19.0
npm 6.14.4

The error occurs during or on completion of some data exchange after the successful TLSv1.2 handshake between the Node JS program and the Azure server. ... While working on this reply I ran a few more experiments to qualify the cause of the invalid handle error and I'm seeing that, in sasl.js:SaslClient.read, which is part of the error stack trace, the target buffer contains the plain text "amqp:link:detach-forced" ... "Unknown link@". I will investigate this more tonight.

Regarding my role in chasing this problem, I am an end user without affiliation with this project or Microsoft. I am a novice javascript developer interested in this project because I have a need to fetch Azure Event Hub data from a web service. My hunch is the problem is an object lifetime issue belonging to one of the 300+ library dependencies (direct and indirect) of this demo and not this project itself.

@sednarb
Copy link
Author

sednarb commented May 18, 2021

The problem occurs after line 74 in the iot-hub-connection.string.js class. I suspect there is a problem with the address:

const receiver = await connection.createReceiver({
source: { address: amqps://${hostName}/messages/events/$management }
});

image

This is suddenly followed by [RST, ACK] and the connection is closed.
Is there perhaps something that needs to be set in the Azure Portal for amqp to work?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants