This project has been moved to the azure-sdk-for-js repo.
This repo is no longer maintained.
Node client library for Azure Event Hubs https://azure.microsoft.com/services/event-hubs
License: MIT License
This project has been moved to the azure-sdk-for-js repo.
This repo is no longer maintained.
https://github.com/Azure/azure-event-hubs-node/blob/master/send_receive/lib/client.js#L224
/**
* Creates a receiver for the given event hub, consumer group, and partition.
* Receivers are event emitters, watch for 'message' and 'errorReceived' events.
*
* @method createReceiver
* @param {string} consumerGroup Consumer group from which to receive.
* @param {(string|Number)} partitionId Partition ID from which to receive.
* @param {*} [options] Options for how you'd like to connect. Only one can be specified.
* @param {(Date|Number)} options.startAfterTime Only receive messages enqueued after the given time.
* @param {string} options.startAfterOffset Only receive messages after the given offset.
* @param {string} options.customFilter If you want more fine-grained control of the filtering.
* See https://github.com/Azure/amqpnetlite/wiki/Azure%20Service%20Bus%20Event%20Hubs for details.
*
* @return {Promise}
*/
See https://github.com/Azure/amqpnetlite/wiki/Azure%20Service%20Bus%20Event%20Hubs for details. Page 404.
and my question is i want to use filter to receive specific device's(like id: 'aaaa') messages
the sender part of code is running on the on-premises server deployed behind a reverse proxy.
My assumption is that above is causing "unhandled rejection amqp disconnected error"?
On the other side I am aware of how the http package exposes an agent property that expects http-proxy-agent.
Is there similar to above in EventHubsClient?
From @timfpark on February 15, 2016 23:40
If messages are still being received from the AMQP connection, calling ephost.stop() fails with the error:
/Users/tim/dev/rhom/enrichProcessor/node_modules/tim-azure-event-hubs/node_modules/amqp10/lib/link.js:101
this.session.connection.sendFrame(attachFrame);
^
TypeError: Cannot read property 'sendFrame' of undefined
at ReceiverLink.Link.attach (/Users/tim/dev/rhom/enrichProcessor/node_modules/tim-azure-event-hubs/node_modules/amqp10/lib/link.js:101:26)
at ReceiverLink.Link._attemptReattach (/Users/tim/dev/rhom/enrichProcessor/node_modules/tim-azure-event-hubs/node_modules/amqp10/lib/link.js:204:8)
at null._onTimeout (/Users/tim/dev/rhom/enrichProcessor/node_modules/tim-azure-event-hubs/node_modules/amqp10/lib/link.js:192:10)
at Timer.listOnTimeout (timers.js:92:15)
This can be repro'ed with the sample on the README.md and a timeout that is large enough that the AMQP connection is established and small enough that you haven't yet processed all of them from your Event Hub.
Copied from original issue: Azure/azure-event-hubs#46
Azure Eventhubs » 0.12.0: http://mvnrepository.com/artifact/com.microsoft.azure/azure-eventhubs/0.12.0
refs:
From @ThomasAnnerel on April 19, 2016 20:13
Dear,
We are trying to use the node js client to send avro contents to the event hub. We use the avcs (https://github.com/mtth/avsc) library blockencoder to create a byte[] containing the schema and avro-object. But when we try to get sample data from the EventHub with Stream Analytics we always get the message that no event where found. If we configure the input as JSON we get a json object with the buffer back.
var avroEncoder = new avro.streams.BlockEncoder(recordTypeBase);
var buffers = [];
avroEncoder.on('data',function(data){
console.log(data.length);buffers.push(data);
});
avroEncoder.on('finish', function() {
console.log('Sending message: ');
var systemProps = {};
systemProps["x-opt-partition-key"] = 'partition1';
var data = Buffer.concat(buffers);
var evtData = new EventData(data, systemProps);
tx.send(body);
done();
});
avroEncoder.write(avroObj);
avroEncoder.end();
Copied from original issue: Azure/azure-event-hubs#118
[Issue describe]
Customer send data to iot hub.
And we have event hub sample, used the iot hub edndpoint to monitor the d2c data, but during about two hour, we will get exception.
[Information]
In device:
Debugger listening on [::]:5858
Connect IoT Hub
[IoT Hub Device] Client (45-sas) connected
{"type":"Alert","message":"IoT Hub device connected","device_id":"45-sas"}
{"sensor_id":234,"time":"2017-07-17T06:10:20.638Z"}
{"sensor_id":234,"time":"2017-07-17T06:11:20.663Z"}
…
<- issue occur in event hub node js command prompt , but client still send the message ->
…
{"sensor_id":234,"time":"2017-07-17T09:13:21.415Z"}
{"sensor_id":234,"time":"2017-07-17T09:14:21.419Z"}
In event hub monitor node js:
Debugger listening on [::]:5894
Created partition receiver: 1
Created partition receiver: 0
{"sensor_id":234,"time":"2017-07-17T06:18:20.725Z"}
{"sensor_id":234,"time":"2017-07-17T06:19:20.728Z"}
…
{"sensor_id":234,"time":"2017-07-17T07:57:21.100Z"}
{"sensor_id":234,"time":"2017-07-17T07:58:21.106Z"}
About 3 hours,
Error from event hub: The message container is being closed (42864). TrackingId:8ed64a36-f063-43c8-97a5-382fe36360cf_B2, SystemTracker:NoSystemTracker, Timestamp:7/17/2017 7:58:23 AM
The code is below:
'use strict';
var EventHubClient = require('azure-event-hubs').Client;
//var connectionString = '[connectionString]';
var connectionString = '[connecting string]';
var eventHubPath = '[path]';
var printError = function (err) {
console.log('Error from event hub:',err.message);
};
var printMessage = function (message) {
//console.log('Message received: ');
console.log(JSON.stringify(message.body));
//console.log('');
};
var client = EventHubClient.fromConnectionString(connectionString, eventHubPath);
client.open()
.then(client.getPartitionIds.bind(client))
.then(function (partitionIds) {
return partitionIds.map(function (partitionId) {
return client.createReceiver('$Default', partitionId, { 'startAfterTime' : Date.now()}).then(function(receiver) {
console.log('Created partition receiver: ' + partitionId)
receiver.on('errorReceived', printError);
receiver.on('message', printMessage);
});
});
})
.catch(printError);
Node version: 6.10.0
azure-event-hubs: 0.0.8
message.systemProperties is empty object in 0.0.8
It is not empty in 0.0.4
I'm currently testing out using Event Hub with Stream Analytics.
I noticed that the change from 0.0.8 to 0.1.2 causes the sent events not to be identified correctly by Stream Analytics and therefore getting dropped.
I've tried many variances, JSON.stringify()
the object added to data
property or even creating Buffer
. Nothing helps.
Also the received events from Event Hub, that was sent using 0.0.8, are not parsed correctly.
body: Section {typecode: 117, content: Buffer(145), multiple: undefined}
content:Buffer(145) [123, 34, 105, …]
multiple:undefined
typecode:117
I understand that the API has breaking changes, but having breaking changes in data is not so nice :)
Also 0.1.2 < 0.8.0, this is a very confusing versioning logic in this cases since 0.1.2 is newer than 0.8.0
https://github.com/AirDwing/iothub-mqtt-demo/blob/master/server/lib/eventhub.js#L29-L35
const receiver = await client.createReceiver('$Default', partitionId, { startAfterTime: Date.now() }); // we use startAfterOffset
receiver.on('errorReceived', async (err) => {
if (err.transport && err.transport.name === 'AmqpProtocolError') {
console.log(`Restart #${partitionId}`);
await createReceiver({ connStr, errorHandler, messageHandler });
} else {
await errorHandler(err);
}
});
when AmqpProtocolError
, we will reconnect eventhubs.
but we( @zhangyf92 ) found that:
2017-08-15 07:35:45 +08:00: worker #1 PID:25215 Restart #2
2017-08-15 09:46:15 +08:00: worker #1 PID:25215 Restart #2
2017-08-15 11:26:39 +08:00: worker #1 PID:25215 Restart #1
2017-08-15 11:26:39 +08:00: worker #2 PID:25217 Restart #0
2017-08-15 11:46:38 +08:00: worker #2 PID:25217 Restart #0
2017-08-15 13:26:10 +08:00: worker #2 PID:25217 Restart #1
2017-08-15 14:36:42 +08:00: worker #1 PID:25215 Restart #0
2017-08-15 15:26:10 +08:00: worker #1 PID:25215 Restart #3
2017-08-15 15:36:16 +08:00: worker #1 PID:25215 Restart #3
2017-08-15 15:36:16 +08:00: worker #2 PID:25217 Restart #0
2017-08-15 16:46:12 +08:00: worker #1 PID:25215 Restart #0
2017-08-15 17:46:14 +08:00: worker #2 PID:25217 Restart #0
2017-08-15 20:46:39 +08:00: worker #2 PID:25217 Restart #1
2017-08-15 21:26:03 +08:00: worker #1 PID:25215 Restart #2
2017-08-15 21:36:09 +08:00: worker #1 PID:25215 Restart #2
2017-08-15 21:46:02 +08:00: worker #2 PID:25217 Restart #1
2017-08-15 22:36:24 +08:00: worker #1 PID:25215 Restart #2
2017-08-16 01:46:43 +08:00: worker #1 PID:25215 Restart #2
2017-08-16 08:46:33 +08:00: worker #1 PID:25215 Restart #2
2017-08-16 08:46:33 +08:00: worker #1 PID:25215 Restart #3
2017-08-19 10:46:27 +08:00: worker #2 PID:25217 Restart #0
after 2017-8-19 never restart again and message lost, cannot received. when we killed the process and restart server, message can be received.
i looked into source code: https://github.com/Azure/azure-event-hubs-node/issues#L40-L47
self.on('newListener', function (event) {
if (event === 'errorReceived') {
amqpReceiverLink.on('errorReceived', onErrorReceived);
}
else if (event === 'message') {
amqpReceiverLink.on('message', onMessage);
}
});
whether add a close event listener can be helpful? ref: https://noodlefrenzy.github.io/node-amqp10/AMQPClient.html#event:connection:closed
I'm attempting to follow https://github.com/Azure/azure-event-hubs-node/tree/master/send_receive and do a send/receive with a partition key set. Debugging the code shows that x-opt-partition-key is being set on the message. But upon receipt the partitionKey is undefined. And as such the messages are distributed across the partitions. Did I miss a code/configuration/etc... step or is this a bug in the library?
Describe the bug
In a long-lived event hub sender, a transport error, such as a socket timeout, that occurs after the connection is established does not trigger the reconnect logic. This is because the rhea-promise library removes the "disconnected" event listener from Rhea when the connection has been opened successfully. However, a socket timeout can occur long after the connection is opened.
To Reproduce
Expected behavior
Either the sender should reopen and reconnect, or an event should be emitted to clients so that the client can handle the disconnect as needed. Because the sender is opened during the send call and is not returned to the client, I don't see a way to attach a "disconnected" listener to the Rhea connection. If no listeners are attached to the Rhea connection, Rhea simply writes an error message to stdout and continues, providing no mechanism for a client app to detect such a socket failure.
Package-name: azure-event-hubs | azure-event-processor-host
Package-version: 0.1.2
node.js version: 9.11.1
OS name and version: MacOSX 10.13
Additional context
Add any other context about the problem here.
Thanks for the repo.
Is there anything in node client that implements feature like EventProcessorHost in C#?
From @ArunAdPushup on April 4, 2017 10:43
Hi,
While trying to send data to eventhubs using azure-event-hubs
package v0.0.7
, I am getting the following error -
Here's the code -
var EventHubClient = require('azure-event-hubs').Client;
var client = EventHubClient.fromConnectionString('Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key', 'myeventhub')
client.open()
.bind(client.createSender.bind(client))
.then(function (tx) {
tx.on('errorReceived', function (err) { console.log(err); });
tx.send({ contents: 'Here is some text sent to partition key my-pk.' }, 'my-pk');
});
I am following Example 3
to create a sender, as shown here.
Copied from original issue: Azure/azure-event-hubs#312
The eventhub viewer website that someone created. It should be good to take a look at.
This is a meta issue that has references to similar issue.
Hi,
I am using Azure EventHubs archive
to store my event hubs data to an azure blob storage. Eventhubs archive stores the data in avro
format. I've written an Azure function
in NodeJS
that listens to the blob trigger event (fired whenever data is sent to Eventhubs and written to the blob storage in avro
format).
I am using the avsc library for doing this.
As soon as the trigger is fired, I want to decode the data sent in avro
format (which is a binary buffer) and convert it into json
.
I tried using the fromBuffer
method by specifying my avro
schema, but it keeps giving me this error -
TypeError: this.buf.utf8Slice is not a function
Here's my code -
const avro = require('avsc');
module.exports = function (context, myBlob) {
const schema = avro.Type.forSchema({
"type" : "record",
"name" : "EventData",
"namespace" : "Microsoft.ServiceBus.Messaging",
"fields" : [ {
"name" : "SequenceNumber",
"type" : "long"
}, {
"name" : "Offset",
"type" : "string"
}, {
"name" : "EnqueuedTimeUtc",
"type" : "string"
}, {
"name" : "SystemProperties",
"type" : {
"type" : "map",
"values" : [ "long", "double", "string", "bytes" ]
}
}, {
"name" : "Properties",
"type" : {
"type" : "map",
"values" : [ "long", "double", "string", "bytes", "null" ]
}
}, {
"name" : "Body",
"type" : [ "null", "bytes" ]
} ]
});
if(myBlob.length){
context.log("JavaScript blob trigger function processed blob \n Name:", context.bindingData.name, "\n Blob Size:", myBlob.length, "Bytes");
context.log(schema.fromBuffer(myBlob)); // myBlob contains the binary avro buffer data
}
context.done();
};
I am storing the iothub annotations in my database with the data. To resume processing where it left of I am querying the database to get the latest enqueuedtime processed and setting this time as the startaftertime parameter. Something like the code below.
However when I run this, the last processed record is re-read from IoT Hub. I have also tried adding 1 millisecond to starttime and it still re-reads the last record. Through the process of elimination I found that adding 1930 milliseconds to starttime (iottime.getTime()+1930) is the point where the last processed record is no longer read.
var iottime = new Date(result.payload[0]["iothub-enqueuedtime"]);
var starttime = iottime.getTime();
... client.createReceiver('blah', partitionId, { 'startAfterTime': starttime }) ...
I've read on event hub documentation that it is possible to send events in batch. If I send an array of events, is it gonna be considered a single event or multiple events?
I am seeing this issue today. It occasionally throws following error.
/home/ubuntu/workspace/axon-winjit-bridge/node_modules/amqp10/lib/frames.js:54
stream.write(buffer);
^
TypeError: Cannot read property 'write' of null
at Object.frames.writeFrame (/home/ubuntu/workspace/axon-winjit-bridge/node_modules/amqp10/lib/frames.js:54:9)
at Connection.sendFrame (/home/ubuntu/workspace/axon-winjit-bridge/node_modules/amqp10/lib/connection.js:333:10)
at ReceiverLink.Link.attach (/home/ubuntu/workspace/axon-winjit-bridge/node_modules/amqp10/lib/link.js:108:27)
at ReceiverLink.Link._attemptReattach (/home/ubuntu/workspace/axon-winjit-bridge/node_modules/amqp10/lib/link.js:237:8)
at Timeout._onTimeout (/home/ubuntu/workspace/axon-winjit-bridge/node_modules/amqp10/lib/link.js:225:10)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)
--sample Code
const client = EventHubClient.fromConnectionString(connectionString);
const receiveAfterTime = Date.now() - 5000;
client.open()
.then(client.getPartitionIds.bind(client))
.then(partitionIds =>
partitionIds.map(partitionId =>
client.createReceiver('$Default', partitionId, { startAfterTime: receiveAfterTime })
.then(receiver => {
receiver.on('errorReceived', logger.error);
receiver.on('message', processEventQueue);
}).catch(logger.error)
)
).catch(logger.error);
From @hmlam on January 8, 2016 23:19
Looking through the code in develop branch it looks like we have not formally defined a good strategy for retry on transient error - something similar to the one we have in .Net. I think this is something that should be in the client layer (not in the Amqp layer). We are doing something similar in Java client so NodeJS should have the same behavior for feature parity.
Thanks
Copied from original issue: Azure/azure-event-hubs#13
Errors such as AmqpMessagePublisher.IdleTimerExpired
are thrown without proper error handling causing the client as well as our own code to crash. This is fundamentally critical...
ping @mrohera @jtaubensee
We're using this library to send our logging from Azure Functions to the Event Hub. These functions are supposed to finish within seconds; they're part of a microservice architecture.
Currently, this library will attempt to reconnect forever when it is unable to establish a connection. The code has been set up that this is a non-blocking issue, however it would keep the node process alive in the background indefinitely (or at least until the connection is reestablished). We would prefer to just connect a couple of times and then disable Event Hub logging.
With the current library, I believe it's impossible to change the policy used to connect to Event Hub. Could you provide the constructor with an extra argument for allowing policy changes?
My eventhub has 32 partitions.
My events are sent in the following format: {body: encodedData, partitionKey: "groupName"};
groupName
represents the name of the field that should be used as a partitionKey.
Is this the right way or should I use the value of the key ?
I'm asking because when sampling data from eventhub, I found that the same key was in two different partitions.
Also, what happens when I don't have 32 different groups ? How the rest of the partitions get filled ?
Thanks.
ANSWER: Use the value of the key, not its name. Example: use "Toyota", not "make"
Hi! Time after time i catch an error.
{"message":"The link 'G25:30407932:/hub2/Partitions/0_3028ebb3-62b8-429e-ba29-ff19bb19f209' is force detached by the broker due to errors occurred in publisher(link39916690). Detach origin: AmqpEventHubPublisher.IdleTimerExpired: Idle timeout: 00:30:00. TrackingId:de0acc420000665a0261149259c008bd_G25_B23, SystemTracker:cryptohub:eventhub:hub216383, Timestamp:9/18/2017 10:51:19 PM","stack":"Error: The link 'G25:30407932:/hub2/Partitions/0_3028ebb3-62b8-429e-ba29-ff19bb19f209' is force detached by the broker due to errors occurred in publisher(link39916690). Detach origin: AmqpEventHubPublisher.IdleTimerExpired: Idle timeout: 00:30:00. TrackingId:de0acc420000665a0261149259c008bd_G25_B23, SystemTracker:cryptohub:eventhub:hub216383, Timestamp:9/18/2017 10:51:19 PM\n at Object.translateError [as translate] (\\100.79.154.12\volume-19-default\6fbefa519d815ec9c983\1918a609e6dd4a39906d5e11ef821ab1\site\wwwroot\node_modules\azure-event-hubs\lib\errors.js:37:15)\n at SenderLink.EventHubSender.onErrorReceived (\\100.79.154.12\volume-19-default\6fbefa519d815ec9c983\1918a609e6dd4a39906d5e11ef821ab1\site\wwwroot\node_modules\azure-event-hubs\lib\sender.js:27:39)\n at emitOne (events.js:101:20)\n at SenderLink.emit (events.js:188:7)\n at SenderLink.Link._detached (\\100.79.154.12\volume-19-default\6fbefa519d815ec9c983\1918a609e6dd4a39906d5e11ef821ab1\site\wwwroot\node_modules\amqp10\lib\link.js:221:10)\n at SenderLink._detached (\\100.79.154.12\volume-19-default\6fbefa519d815ec9c983\1918a609e6dd4a39906d5e11ef821ab1\site\wwwroot\node_modules\amqp10\lib\sender_link.js:236:41)\n at SenderLink.Link._detachReceived (\\100.79.154.12\volume-19-default\6fbefa519d815ec9c983\1918a609e6dd4a39906d5e11ef821ab1\site\wwwroot\node_modules\amqp10\lib\link.js:204:8)\n at Session._processDetachFrame (\\100.79.154.12\volume-19-default\6fbefa519d815ec9c983\1918a609e6dd4a39906d5e11ef821ab1\site\wwwroot\node_modules\amqp10\lib\session.js:335:45)\n at Session._processFrame (\\100.79.154.12\volume-19-default\6fbefa519d815ec9c983\1918a609e6dd4a39906d5e11ef821ab1\site\wwwroot\node_modules\amqp10\lib\session.js:302:61)\n at Connection._processFrameEH (\\100.79.154.12\volume-19-default\6fbefa519d815ec9c983\1918a609e6dd4a39906d5e11ef821ab1\site\wwwroot\node_modules\amqp10\lib\session.js:186:49)\n at emitOne (events.js:101:20)\n at Connection.emit (events.js:188:7)\n at Connection._receiveAny (\\100.79.154.12\volume-19-default\6fbefa519d815ec9c983\1918a609e6dd4a39906d5e11ef821ab1\site\wwwroot\node_modules\amqp10\lib\connection.js:426:12)\n at Connection._receiveData (\\100.79.154.12\volume-19-default\6fbefa519d815ec9c983\1918a609e6dd4a39906d5e11ef821ab1\site\wwwroot\node_modules\amqp10\lib\connection.js:357:8)\n at . (\\100.79.154.12\volume-19-default\6fbefa519d815ec9c983\1918a609e6dd4a39906d5e11ef821ab1\site\wwwroot\node_modules\amqp10\lib\connection.js:515:38)\n at emitOne (events.js:96:13)","transport":{"name":"AmqpProtocolError","message":"amqp:link:detach-forced:The link 'G25:30407932:/hub2/Partitions/0_3028ebb3-62b8-429e-ba29-ff19bb19f209' is force detached by the broker due to errors occurred in publisher(link39916690). Detach origin: AmqpEventHubPublisher.IdleTimerExpired: Idle timeout: 00:30:00. TrackingId:de0acc420000665a0261149259c008bd_G25_B23, SystemTracker:cryptohub:eventhub:hub216383, Timestamp:9/18/2017 10:51:19 PM","condition":"amqp:link:detach-forced","description":"The link 'G25:30407932:/hub2/Partitions/0_3028ebb3-62b8-429e-ba29-ff19bb19f209' is force detached by the broker due to errors occurred in publisher(link39916690). Detach origin: AmqpEventHubPublisher.IdleTimerExpired: Idle timeout: 00:30:00. TrackingId:de0acc420000665a0261149259c008bd_G25_B23, SystemTracker:cryptohub:eventhub:hub216383, Timestamp:9/18/2017 10:51:19 PM","errorInfo":{}},"codeBlock":"HUB2: Partcion 0","level":"error","timestamp":"2017-09-18T22:51:18.648Z"}
Does anybody know what is wrong? And how i can handle this error?
From @tameraw on January 9, 2017 21:46
From @albhardy on December 21, 2016 8:17
OS and version used: Windows 10
Node.js version: v6.4.0
npm version: 3.10.3
list of installed packages:
[email protected]
D:\DEV\AZURE\IOTHUB\simulateddevice
+-- [email protected]
| +-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | +-- [email protected]
| | +-- [email protected]
| | +-- [email protected]
| | | `-- [email protected]
| | +-- [email protected]
| | +-- [email protected]
| | | +-- [email protected]
| | | +-- [email protected]
| | | +-- [email protected]
| | | +-- [email protected]
| | | `-- [email protected]
| | +-- [email protected]
| | | +-- [email protected]
| | | +-- [email protected]
| | | +-- [email protected]
| | | +-- [email protected]
| | | +-- [email protected]
| | | | `-- [email protected]
| | | +-- [email protected]
| | | +-- [email protected]
| | | +-- [email protected]
| | | | `-- [email protected]
| | | +-- [email protected]
| | | | +-- [email protected]
| | | | | +-- [email protected]
| | | | | +-- [email protected]
| | | | | +-- [email protected]
| | | | | | `-- [email protected]
| | | | | +-- [email protected]
| | | | | `-- [email protected]
| | | | +-- [email protected]
| | | | | `-- [email protected]
| | | | +-- [email protected]
| | | | | +-- [email protected]
| | | | | +-- [email protected]
| | | | | | `-- [email protected]
| | | | | `-- [email protected]
| | | | `-- [email protected]
| | | | `-- [email protected]
| | | +-- [email protected]
| | | | +-- [email protected]
| | | | +-- [email protected]
| | | | +-- [email protected]
| | | | `-- [email protected]
| | | +-- [email protected]
| | | | +-- [email protected]
| | | | +-- [email protected]
| | | | | +-- [email protected]
| | | | | +-- [email protected]
| | | | | `-- [email protected]
| | | | `-- [email protected]
| | | | +-- [email protected]
| | | | +-- [email protected]
| | | | +-- [email protected]
| | | | +-- [email protected]
| | | | | `-- [email protected]
| | | | +-- [email protected]
| | | | +-- [email protected]
| | | | | `-- [email protected]
| | | | +-- [email protected]
| | | | +-- [email protected]
| | | | `-- [email protected]
| | | +-- [email protected]
| | | +-- [email protected]
| | | +-- [email protected]
| | | +-- [email protected]
| | | | `-- [email protected]
| | | +-- [email protected]
| | | +-- [email protected]
| | | +-- [email protected]
| | | +-- [email protected]
| | | | `-- [email protected]
| | | `-- [email protected]
| | +-- [email protected]
| | +-- [email protected]
| | +-- [email protected]
| | | `-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | `-- [email protected]
| `-- [email protected]
+-- [email protected]
| `-- [email protected]
| +-- [email protected]
| | +-- [email protected]
| | +-- [email protected]
| | +-- [email protected]
| | +-- [email protected]
| | +-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| | +-- [email protected]
| | +-- [email protected]
| | +-- [email protected]
| | `-- [email protected]
| | `-- [email protected]
| `-- [email protected]
| +-- [email protected]
| | +-- [email protected]
| | | +-- [email protected]
| | | | `-- [email protected]
| | | `-- [email protected]
| | `-- [email protected]
| `-- [email protected]
+-- [email protected]
| `-- [email protected]
| `-- [email protected]
`-- [email protected]
`-- [email protected]
+-- [email protected]
| `-- [email protected]
+-- [email protected]
| +-- [email protected]
| | `-- [email protected]
| `-- [email protected]
+-- [email protected]
| `-- [email protected]
| `-- [email protected]
+-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | +-- [email protected]
| | +-- [email protected]
| | | +-- [email protected]
| | | +-- [email protected]
| | | | `-- [email protected]
| | | | +-- [email protected]
| | | | `-- [email protected]
| | | `-- [email protected]
| | +-- [email protected]
| | | +-- [email protected]
| | | | `-- [email protected]
| | | `-- [email protected]
| | +-- [email protected]
| | | +-- [email protected]
| | | | `-- [email protected]
| | | +-- [email protected]
| | | +-- [email protected]
| | | | +-- [email protected]
| | | | | `-- [email protected]
| | | | | +-- [email protected]
| | | | | +-- [email protected]
| | | | | +-- [email protected]
| | | | | `-- [email protected]
| | | | +-- [email protected]
| | | | `-- [email protected]
| | | +-- [email protected]
| | | | `-- [email protected]
| | | +-- [email protected]
| | | | `-- [email protected]
| | | +-- [email protected]
| | | +-- [email protected]
| | | +-- [email protected]
| | | +-- [email protected]
| | | | `-- [email protected]
| | | +-- [email protected]
| | | +-- [email protected]
| | | | +-- [email protected]
| | | | | +-- [email protected]
| | | | | `-- [email protected]
| | | | | `-- [email protected]
| | | | +-- [email protected]
| | | | +-- [email protected]
| | | | `-- [email protected]
| | | `-- [email protected]
| | | +-- [email protected]
| | | `-- [email protected]
| | +-- [email protected]
| | | `-- [email protected]
| | +-- [email protected]
| | | `-- [email protected]
| | | `-- [email protected]
| | +-- [email protected]
| | | `-- [email protected]
| | `-- [email protected]
| | +-- [email protected]
| | | `-- [email protected]
| | `-- [email protected]
| `-- [email protected]
| `-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
| +-- [email protected]
| | `-- [email protected]
| | `-- [email protected]
| `-- [email protected]
| `-- [email protected]
| `-- [email protected]
+-- [email protected]
| `-- [email protected]
| `-- [email protected]
| `-- [email protected]
+-- [email protected]
+-- [email protected]
| `-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
| +-- [email protected]
| | +-- [email protected]
| | `-- [email protected]
| `-- [email protected]
| +-- [email protected]
| `-- [email protected]
`-- [email protected]
I run simple_sample_device_with_sas.js example and experienced following protocols are not working:
Could not connect: connect ETIMEDOUT 40.83.177.42:8883
Could not connect: Error: AMQP Transport: Could not connect
However, these protocols work:
Is there anything else that needs to be configured to enable send/receive MQTT on Windows? I also noticed Device Explorer
is also unable to receive message from IOT Hub:
Copied from original issue: Azure/azure-iot-sdk-node#6
Copied from original issue: Azure/azure-event-hubs-dotnet#88
Currently using latest azure-event-hubs in node, 0.0.8. It's hosted in a docker container on azure. We are using azure-iothub 1.1.9 in the same project. Probably it's not related. But we are using the iothub as our event hub (same connection string)
We have some code that looks like this:
eventHubClient.open()
.then(() => {
log.info('Getting partition IDs...')
return eventHubClient.getPartitionIds()
})
.then(partitionIds => {
log.info('Setting up receivers for partitions: ' + partitionIds.join(','))
return partitionIds.map(partitionId => {
return eventHubClient.createReceiver('$Default', partitionId, {'startAfterTime': Date.now()}).then(receiver => {
log.info('Receiver up: ', partitionId)
receiver.on('errorReceived', (err) => {
log.error('Error from event hub: ', err, 'bailing out')
process.exit(1)
})
receiver.on('message', handleMessage)
})
})
}).catch((error) => {
log.error('Error when connecting to event hub: ', error.message)
process.exit()
})
Some of the problems the azure-event-hub causes will cause this to crash (like the "Message container is being closed" bug #26 ). But for this bug, sometimes we just stop getting messages.
We simply do not get any more messages. We are sure that other messages are being delivered to the event hub. When we restart the project (and hence resubscribe), then we start getting messages again. This has happened about 3 times in as many weeks. Usually outside of our office hours, so it's probably not a side effect of something we did.
Expected:
Messages should be delivered
If message delivery fails for some reason, an error or something should be delivered so we can recover
Actual:
Messages stop being delivered, with no indication
Hey!
We are currently using "azure-event-hubs": "0.0.8"
in our node project. After letting it run for some hours, we sometimes encounter this error:
Error from event hub: { Error: The message container is being closed (94995). TrackingId:<sometrackingid>, SystemTracker:NoSystemTracker, Timestamp:5/23/2017 4:14:51 PM
at Object.translateError [as translate] (/usr/src/app/node_modules/azure-event-hubs/lib/errors.js:37:15)
at ReceiverLink.onErrorReceived (/usr/src/app/node_modules/azure-event-hubs/lib/receiver.js:32:39)
at emitOne (events.js:101:20)
at ReceiverLink.emit (events.js:188:7)
at ReceiverLink.Link._detached (/usr/src/app/node_modules/amqp10/lib/link.js:221:10)
at ReceiverLink.Link._detachReceived (/usr/src/app/node_modules/amqp10/lib/link.js:204:8)
at Session._processDetachFrame (/usr/src/app/node_modules/amqp10/lib/session.js:335:45)
at Session._processFrame (/usr/src/app/node_modules/amqp10/lib/session.js:302:61)
at Connection._processFrameEH (/usr/src/app/node_modules/amqp10/lib/session.js:186:49)
at emitOne (events.js:101:20)
at Connection.emit (events.js:188:7)
at Connection._receiveAny (/usr/src/app/node_modules/amqp10/lib/connection.js:426:12)
at Connection._receiveData (/usr/src/app/node_modules/amqp10/lib/connection.js:357:8)
at TlsTransport.<anonymous> (/usr/src/app/node_modules/amqp10/lib/connection.js:515:38)
at emitOne (events.js:96:13)
at TlsTransport.emit (events.js:188:7)
transport:
{ AmqpProtocolError: com.microsoft:container-close:The message container is being closed (94995). TrackingId:<sometrackingid>, SystemTracker:NoSystemTracker, Timestamp:5/23/2017 4:14:51 PM
at Object.errors.wrapProtocolError (/usr/src/app/node_modules/amqp10/lib/errors.js:10:12)
at ReceiverLink.Link._detached (/usr/src/app/node_modules/amqp10/lib/link.js:221:42)
at ReceiverLink.Link._detachReceived (/usr/src/app/node_modules/amqp10/lib/link.js:204:8)
at Session._processDetachFrame (/usr/src/app/node_modules/amqp10/lib/session.js:335:45)
at Session._processFrame (/usr/src/app/node_modules/amqp10/lib/session.js:302:61)
at Connection._processFrameEH (/usr/src/app/node_modules/amqp10/lib/session.js:186:49)
at emitOne (events.js:101:20)
at Connection.emit (events.js:188:7)
at Connection._receiveAny (/usr/src/app/node_modules/amqp10/lib/connection.js:426:12)
at Connection._receiveData (/usr/src/app/node_modules/amqp10/lib/connection.js:357:8)
at TlsTransport.<anonymous> (/usr/src/app/node_modules/amqp10/lib/connection.js:515:38)
at emitOne (events.js:96:13)
at TlsTransport.emit (events.js:188:7)
at TLSSocket.<anonymous> (/usr/src/app/node_modules/amqp10/lib/transport/tls_transport.js:29:49)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:188:7)
name: 'AmqpProtocolError',
message: 'com.microsoft:container-close:The message container is being closed (94995). TrackingId:<sometrackingid>, SystemTracker:NoSystemTracker, Timestamp:5/23/2017 4:14:51 PM',
condition: 'com.microsoft:container-close',
description: 'The message container is being closed (94995). TrackingId:<sometrackingid>, SystemTracker:NoSystemTracker, Timestamp:5/23/2017 4:14:51 PM',
errorInfo: {} } }
(I just removed the tracking id).
The code looks something like this:
eventHubClient.open()
.then(() => {
return eventHubClient.getPartitionIds()
})
.then(partitionIds => {
return partitionIds.map(partitionId => {
return eventHubClient.createReceiver('$Default', partitionId, {'startAfterTime': Date.now()}).then(receiver => {
receiver.on('errorReceived', (err) => {
log.info('Error from event hub: ', err)
})
After that, the code still runs, but we are not getting any messages or errors. The error appeared 3 times (we have 4 partititons).
I think for now we'll make sure to restart the process when this happens, to reset. But that's not optimal
Hi,
I have two eventhubs having 8 partitions each.
My partition key is "ticker"
and the data looks like: {ticker: "MSFT", price: 100}
I'm tracking and sending 17 different tickers, which means 17 different PartitionKey
values.
When sampling (with different time ranges, from 1mn to 10mn), it says that No event was received from N Partitions (changes everytime I sample), and when I lookup the data, there are less keys than 17 (I double checked from the producer and the producer is sending all keys)
How can I debug this ? Since EventHubs hashes the PartitionKey to send the event to a specific Partition, what is happening in this case ? (17 different keys, 8 Partitions, N empty partitions)
Thanks.
ref #34, we have no idea when the application went die.
although we have recorded the message offset but it's only used when restarting startAfterOffset
.
we want to make a daemon process, to check the queue offset and to diff from the one we store.
Hello Folks,
Any plans to add GoLang support here?
as #26 reported connection closed often.
and i have no idea about the err handling.
const createReceiver = async ({ connStr = '', partitionIds = [], errorHandler = defaultErrorHandler, messageHandler = defaultMessageHandler } = {}) => {
const client = EventHubClient.fromConnectionString(connStr);
await client.open();
partitionIds.forEach(async (partitionId) => {
// how to make startAfterTime to the time connection closed?
const receiver = await client.createReceiver('$Default', partitionId, { startAfterTime: Date.now() });
receiver.on('errorReceived', async (err) => {
// right?
if (err.transport && err.transport.name === 'AmqpProtocolError') {
console.log(`worker #${cluster.worker.id} PID:${process.pid} Restart #${partitionId}`);
// right?
await createReceiver({ connStr, partitionIds: [partitionId], errorHandler, messageHandler });
} else {
await errorHandler(err);
}
});
receiver.on('message', messageHandler);
});
};
i guess perhaps it may be related to checkpoint and storage,
like sample in dot net: https://github.com/Azure/azure-event-hubs/blob/master/samples/DotNet/Microsoft.Azure.EventHubs/SampleEphReceiver/SimpleEventProcessor.cs
Hi there, the Event hub freezes and not responding after a long run. Could anyone advise how we could eliminate this timeout issues?
{ Error: The link 'G10:5173588:/shioeventhub/Partitions/0_e1af6238-00e5-40f5-b822-7206730cdbeb' is force detached by the broker due to errors occurred in publisher(link7376012). Detach origin: AmqpEventHubPublisher.IdleTimerExpired: Idle timeout: 00:30:00. TrackingId:51cec16f0000539e00708c8c5a600968_G10_B25, SystemTracker:shioeventhub:eventhub:shioeventhub16383, Timestamp:1/18/2018 3:20:02 PM16383, Timestamp:1/18/2018 3:20:02 PM
at Object.translateError [as translate] (/opt/project-tcp-redirect-to-eventhub/node_modules/azure-event-hubs/lib/errors.js:37:15)
at SenderLink.onErrorReceived (/opt/project-tcp-redirect-to-eventhub/node_modules/azure-event-hubs/lib/sender.js:27:39)
at emitOne (events.js:121:20)
at SenderLink.emit (events.js:211:7)
at SenderLink.Link._detached (/opt/project-tcp-redirect-to-eventhub/node_modules/amqp10/lib/link.js:221:10)
at SenderLink._detached (/opt/project-tcp-redirect-to-eventhub/node_modules/amqp10/lib/sender_link.js:236:41)
at SenderLink.Link._detachReceived (/opt/project-tcp-redirect-to-eventhub/node_modules/amqp10/lib/link.js:204:8)
at Session._processDetachFrame (/opt/project-tcp-redirect-to-eventhub/node_modules/amqp10/lib/session.js:335:45)
at Session._processFrame (/opt/project-tcp-redirect-to-eventhub/node_modules/amqp10/lib/session.js:302:61)
at Connection._processFrameEH (/opt/project-tcp-redirect-to-eventhub/node_modules/amqp10/lib/session.js:186:49)
at emitOne (events.js:121:20)
at Connection.emit (events.js:211:7)
at Connection._receiveAny (/opt/project-tcp-redirect-to-eventhub/node_modules/amqp10/lib/connection.js:426:12)
at Connection._receiveData (/opt/project-tcp-redirect-to-eventhub/node_modules/amqp10/lib/connection.js:357:8)
at TlsTransport. (/opt/project-tcp-redirect-to-eventhub/node_modules/amqp10/lib/connection.js:515:38)
at emitOne (events.js:116:13)
transport:
{ AmqpProtocolError: amqp:link:detach-forced:The link 'G10:5173588:/shioeventhub/Partitions/0_e1af6238-00e5-40f5-b822-7206730cdbeb' is force detached by the broker due to errors occurred in publisher(link7376012). Detach origin: AmqpEventHubPublisher.IdleTimerExpired: Idle timeout: 00:30:00. TrackingId:51cec16f0000539e00708c8c5a600968_G10_B25, SystemTracker:shioeventhub:eventhub:shioeventhub
at Object.errors.wrapProtocolError (/opt/project-tcp-redirect-to-eventhub/node_modules/amqp10/lib/errors.js:10:12)
at SenderLink.Link._detached (/opt/project-tcp-redirect-to-eventhub/node_modules/amqp10/lib/link.js:221:42)
at SenderLink._detached (/opt/project-tcp-redirect-to-eventhub/node_modules/amqp10/lib/sender_link.js:236:41)
at SenderLink.Link._detachReceived (/opt/project-tcp-redirect-to-eventhub/node_modules/amqp10/lib/link.js:204:8)
at Session._processDetachFrame (/opt/project-tcp-redirect-to-eventhub/node_modules/amqp10/lib/session.js:335:45)
at Session._processFrame (/opt/project-tcp-redirect-to-eventhub/node_modules/amqp10/lib/session.js:302:61)
at Connection._processFrameEH (/opt/project-tcp-redirect-to-eventhub/node_modules/amqp10/lib/session.js:186:49)
at emitOne (events.js:121:20)
at Connection.emit (events.js:211:7)
at Connection._receiveAny (/opt/project-tcp-redirect-to-eventhub/node_modules/amqp10/lib/connection.js:426:12)
at Connection._receiveData (/opt/project-tcp-redirect-to-eventhub/node_modules/amqp10/lib/connection.js:357:8)
at TlsTransport. (/opt/project-tcp-redirect-to-eventhub/node_modules/amqp10/lib/connection.js:515:38)
at emitOne (events.js:116:13)
at TlsTransport.emit (events.js:211:7)
at TLSSocket. (/opt/project-tcp-redirect-to-eventhub/node_modules/amqp10/lib/transport/tls_transport.js:29:49)
at emitOne (events.js:116:13)
name: 'AmqpProtocolError',
message: 'amqp:link:detach-forced:The link 'G10:5173588:/shioeventhub/Partitions/0_e1af6238-00e5-40f5-b822-7206730cdbeb' is force detached by the broker due to errors occurred in publisher(link7376012). Detach origin: AmqpEventHubPublisher.IdleTimerExpired: Idle timeout: 00:30:00. TrackingId:51cec16f0000539e00708c8c5a600968_G10_B25, SystemTracker:shioeventhub:eventhub:shioeventhub16383, Timestamp:1/18/2018 3:20:02 PM',16383, Timestamp:1/18/2018 3:20:02 PM',
condition: 'amqp:link:detach-forced',
description: 'The link 'G10:5173588:/shioeventhub/Partitions/0_e1af6238-00e5-40f5-b822-7206730cdbeb' is force detached by the broker due to errors occurred in publisher(link7376012). Detach origin: AmqpEventHubPublisher.IdleTimerExpired: Idle timeout: 00:30:00. TrackingId:51cec16f0000539e00708c8c5a600968_G10_B25, SystemTracker:shioeventhub:eventhub:shioeventhub
errorInfo: {} } }
From @hmlam on January 26, 2016 19:32
In .Net client the connection string can have the following keyword for specifying connection endpoints:
The difference is that Endpoint requires a URL format, while HostName has no such requirement and internally will create the SB:// URL from hostname.
Event though the original requirement comes from IoT, HostName keyword is designed to be supported by all SB scenario in mind, and so the NodeJS library should also support it.
Copied from original issue: Azure/azure-event-hubs#16
I have a streamed data transferred to Azure Event Hub via my server.
Problem I am facing is I create a client and sender everytime I receive a data from my server to transfer to Azure Event Hub but the error I get is :
AmqpOverCapacityError: Out of available handles (Max = 255)]
When I try to close the client after the data is sent the error I get is :
Unhandled rejection AmqpProtocolError: amqp:link:detach-forced:detach-forced
I am not sure if this is an issue or an error caused by me but I am trying to figure out the best solution.
If you can help me with that, I will be pleased.
From @albhardy on December 22, 2016 8:2
Is it possible to configure EventHubClient.fromConnectionString(connectionString)
to receive Azure IOT/Event Hub AMQP message over WebSocket to avoid corporate firewall issue?
Copied from original issue: Azure/azure-event-hubs#295
How to reproduce:
Node: 10.0.0
Npm: 5.6.0
tsc: 2.7.2
azure-event-hubs: 0.1.2
Here's the stack trace using node --trace-warnings
(node:15668) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 released listeners added. Use emitter.setMaxListeners() to increase limit
at _addListener (events.js:244:19)
at Sender.addListener (events.js:261:10)
at Promise (C:\...\node_modules\azure-event-hubs\dist\lib\eventHubSender.js:231:30)
at new Promise (<anonymous>)
at EventHubSender._trySend (C:\...\node_modules\azure-event-hubs\dist\lib\eventHubSender.js:175:34)
at EventHubSender.<anonymous> (C:\...\node_modules\azure-event-hubs\dist\lib\eventHubSender.js:68:35)
at Generator.next (<anonymous>)
at C:\...\node_modules\azure-event-hubs\dist\lib\eventHubSender.js:9:71
at new Promise (<anonymous>)
at __awaiter (C:\...\node_modules\azure-event-hubs\dist\lib\eventHubSender.js:5:12)
FIX: Make sure to await on the client.send() method.
I know this is an already known issue by the developer(s) .
This issue is opened to track the progress because this feature is crucial and some people like me need it to make their parallelized queries work correctly (PARTITION BY when grouping is not possible right now because of this issue)
Thanks.
From @shpros on November 8, 2016 23:39
As of this writing, NPM says 0.0.4 is the latest of 4 releases
, but the releases tab of this GitHub project says that v0.8.0
is the most recent of 14 releases going back to v0.3.0
.
Copied from original issue: Azure/azure-event-hubs#292
Are you considering adding support for the SAStoken for this library?
Example:
var client = EventHubClient.EventHubClient.fromConnectionString('Endpoint=sb://my-hub.servicebus.windows.net/;SharedAccessSignature=' + encodeURIComponent('sr=sb%3a%2f%2fmy-hub.servicebus.windows.net%2fdatacollectoroutbox%2fpublishers%2ffb5ec0e2-da48-43b2-9abf-dee0388a1457&sig=XXXXXXXXXXXXXXX&se=4640345124&skn=SendAccessPolicy'), 'queue')
I have event hub with 4 partitions (and 4 TPU) with 2500 events per each partition.
I've executed script in single Node.js instance, which creates 4 receivers. Total execution time is 3m2.943s
After that I've executed simultaneously 4 instances, each had 1 receiver. The average execution time is 56s.
Also I have C# .NET application, which creates 4 receivers (each in separate thread). Total execution time is 58s.
Question: Why single Node.js instance cannot meet the execution time of the multi-threaded C# .NET application? Is it possible to implement non-blocking reading from multiple partitions in Node.js?
From @ThomasAnnerel on June 1, 2016 6:30
Dear
We are using an Azure App Service to push messages on a eventhub (+- 2,5 milj messages/hour). The thing we are struggling with a lot is finding a best practice for reusing clients and senders and how to host it in express.
Possibilites:
I think we are sometimes hitting the connection limit on ServiceBus (+- 5000 connections)
Copied from original issue: Azure/azure-event-hubs#163
Node version: v6.10.0
NPM version: 3.10.8
package azure-event-hubs version: 0.0.6
reference the azure-event-hubs and import the client, sender.
Met following compile errors:
node_modules/azure-event-hubs/lib/client.d.ts(4,26): error TS2307: Cannot find module 'bluebird'.
node_modules/azure-event-hubs/lib/receiver.d.ts(5,26): error TS2307: Cannot find module 'bluebird'.
node_modules/azure-event-hubs/lib/sender.d.ts(4,26): error TS2307: Cannot find module 'bluebird'.
once click into the error (in vscode output view), the error and red line just disappear.
Check the typings.json:
{
"name": "azure-event-hubs",
"dependencies": {
"bluebird": "registry:npm/bluebird#3.3.4+20160802085254"
},
"globalDependencies": {
"node": "registry:dt/node#6.0.0+20160807145350"
}
}
but the bluebird version is different in package.json:
"dependencies": {
"amqp10": "3.4.1",
"azure-iot-common": "1.1.3",
"bluebird": "^3.4.7",
"uuid": "^3.0.1"
},
Found some clue in stackoverflow about typings, tried: typings install bluebird, problem solve.
Trying to implement a device-to-cloud receiver on browser. Console code in "Get started with IoT Hub (Node)" documentation works fine. Encountered following errors on browser:
Now the while opening the connection at run time we are getting "cannot open TCP connection" error:
var EventHubClient = require('azure-event-hubs').Client;
var client = EventHubClient.fromConnectionString('Endpoint=sb://my-servicebus-namespace.servicebus.windows.net/;SharedAccessKeyName=my-SA-name;SharedAccessKey=my-SA-key', 'myeventhub')
client.open()
.then(function() {
client.createSender();
})
.then(function (tx) {
tx.on('errorReceived', function (err) { console.log(err); });
tx.send({ contents: 'Here is some text sent to partition key my-pk.' }, 'my-pk');
});
it should be
.then(function() {
return client.createSender();
})
Btw, createSender v1 does not work properly, you can input whatever num in postion 'my-pk', and this function will send the message to a random partition.
I put '200' in the second param postion, and it just sended my message to partition 1.
CreateSender v2 is ok.
Sorry for my bad grammar.
Hi!
I'd like to connect to one of my eventhubs like this:
const EventHubClient = require('azure-event-hubs').Client
// copied from azure portal
const connectionString = 'Endpoint=sb://XXX.servicebus.windows.net/;SharedAccessKeyName=XXX;SharedAccessKey=XXX=;EntityPath=test'
const client = EventHubClient.fromConnectionString(connectionString)
client.open()
.then(() => {
console.log('connected')
})
.catch(err => {
console.error('failed', err)
})
However, nothing happens (nothing gets printed on console) and process waits forever.
Am I missing something?
I found from npm that there is a tim-event-processor-host lib, but seems it's outdated. is there plan to build one EPH? same as Java & .Net. thanks.
https://github.com/Azure/azure-event-hubs-node/blob/master/send_receive/lib/receiver.js#L35
are there any events can listen device online/offline?
From @kenr on June 13, 2016 14:6
Using NodeJS API, EventHubClient.createReceiver result in an error:
outStream.write(buffer);
^
TypeError: Cannot read property 'write' of null
at AttachFrame.Frame.write (c:\Users\myusername\dev\msft\web-backend\node_modules\amqp10\lib\frames\frame.js:86:12)
at Connection.sendFrame (c:\Users\myusername\dev\msft\web-backend\node_modules\amqp10\lib\connection.js:336:9)
at ReceiverLink.Link.attach (c:\Users\myusername\dev\msft\web-backend\node_modules\amqp10\lib\link.js:101:27)
at ReceiverLink.Link._attemptReattach (c:\Users\myusername\dev\msft\web-backend\node_modules\amqp10\lib\link.js:204:8)
at Timeout._onTimeout (c:\Users\myusername\dev\msft\web-backend\node_modules\amqp10\lib\link.js:192:10)
at tryOnTimeout (timers.js:224:11)
at Timer.listOnTimeout (timers.js:198:5)
I'm not able to get any of the messages put into the IoT Hub by a device (on the service side). This issue is also reported here: https://github.com/Azure/azure-iot-sdks/issues/621
Copied from original issue: Azure/azure-event-hubs#167
const client = EventHubClient.fromConnectionString(connectionString);
client.open()
.then(client.getPartitionIds.bind(client))
.then(partitionIds => partitionIds.map(partitionId => client.createReceiver('$Default', partitionId, { startAfterTime: Date.now()}).then((receiver) => {
console.log(`Created partition receiver: ${partitionId}`);
receiver.on('errorReceived', printError);
receiver.on('message', printMessage);
})))
.catch(printError);
convert to es7 async/await:
const client = EventHubClient.fromConnectionString(connStr);
(async()=>{
const c = await client.open();
const partitionIds = await client.getPartitionIds(c);// why pass in c
partitionIds.forEach(partitionId =>{
const receiver = await client.createReceiver('$Default', partitionId, { startAfterTime: Date.now()}); // why not pass in c
receiver.on('errorReceived', printError);
receiver.on('message', printMessage);
});
})();
recommend:
const client = EventHubClient.fromConnectionString(connStr);
(async()=>{
// open like mysql and other common packages
client.open();
const partitionIds = await client.getPartitionIds();
partitionIds.forEach(partitionId =>{
const receiver = await client.createReceiver('$Default', partitionId, { startAfterTime: Date.now()});
receiver.on('errorReceived', printError);
receiver.on('message', printMessage);
});
})();
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.