[Azure iot SDK node js]event hub receive data error "message container is being closed"
Closed this issue · 6 comments
[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);
You are simply using the simple_eventhubs_client.js?
The connection string you are using. You got it from where? If you could supply the connection string in reply WITHOUT POSTING THE KEY, I repeat, WITHOUT POSTING THE KEY, that could be helpful.
Hi Anthonyvercolano,
Thanks for your help, may I know what is "WITHOUT POSTING THE KEY", it's mean don't paste the connection string in the article ? so you had help us to replace the information :
var connectionString = '[connecting string]';
var eventHubPath = '[path]';
or you have other meaning, thanks.
Typically when you create a device you have (eg for an IoT Hub) HostName=test.azure-devices.net;DeviceId=mycooldevice;SharedAccessKey=<THIS IS WHAT SHOULD NOT BE IN THE POST>
Actually all I really need is the HostName
portion of the connection string. From that I can look up logs and get a better Idea of what happened. So feel comfortable just positing something like: test.azure-devices.net
It appears that the client needs to handle this and retry the connection. See this: https://stackoverflow.com/questions/42563043/azure-event-hub-servicebusexception-causing-skipped-messages.
@kuomingwu - We have a new preview version "0.1.0" of the event hubs node.js client. This client was re-written from scratch. Please try the new version and let us know if you still see issues. You can find examples over here.