carboncalculated / node-pachube-stream Goto Github PK
View Code? Open in Web Editor NEWA streaming TCP client for the pachube TCP Server for Nodejs
Home Page: http://www.carboncalculated.com
License: MIT License
A streaming TCP client for the pachube TCP Server for Nodejs
Home Page: http://www.carboncalculated.com
License: MIT License
Many thanks for publishing this extremely useful module :-)
Hope I'm not stretching this further than you intended.
I want to do a number of datastream subscribes and handle changes on any of them as they occur.
I can do this if each has its own connection. However, not on the same connection.
var http=require('http');
var hostname='api.pachube.com';
var key="my-key-here";
var Connection = require("pachube-stream").Connection;
// open connection
var conn = new Connection(key);
conn.on("error", function(error) {
return console.log('connection error',error);
});
// handle subscribe acknowledgement
function complete (data) {
console.log('subscribed to: ',data.resource);
}
// handle data arrival
function change (data) {
value=data.body.current_value;
when=data.body.at;
what=data.resource;
return console.log(when+': what='+what+': value='+value);
}
// the feeds - there will be many
var ds1 = conn.subscribe("/feeds/1539/datastreams/1");
ds1.on("complete", complete);
ds1.on("data", change);
// need to comment out these 3 lines to make one connection work
var ds2 = conn.subscribe("/feeds/1539/datastreams/2");
ds2.on("complete", complete);
ds2.on("data", change);
unless I comment out the above 3 lines I get this back this connection error:
{ stack: [Getter/Setter],
arguments: [ 'emitEvent', undefined ],
type: 'non_object_property_call',
message: [Getter/Setter] }
Have looked at code but can't see why this is happening.
Is this a bug or am I misusing it?
paul at virtual-techno.com
Richard,
The mod you made to allow this to subscribe to multiple streams has been working fine for many months.
However, I noticed that re-installing it on another platform did not work.
Just tried again, this time with a BeagleBone running Angstrom v2012.01-core - Kernel 3.2.5+ and the old problem reappeared.
Could you have forgotten to push it up to NPM?
Thx. Paul
I'm working on a version of my stuff that will resubscribe when pachube drops a subscription (possibly due to a server restart or whatever). I detect this with a watchdog timer as there is no other indication that this has happened.
I thought it best to unsubscribe everything and then resubscribe so I tried the unsubscribe function in this node module for the first time. It comes back on complete but I notice when testing that the unsubscribe has not taken place.
Looking at the code it seems that a new token is generated for the unsubscribe request. The pachube spec requires that the token be the one used to subscribe in the first place. The app has this and can pass it back in but it's ignored.
Paul
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.