Closed fokusferit closed 9 years ago
Sorry for the additional post, but i think i found one Bug which is related to subscriptions and using mongodb.
With the current implementation, i'm getting this error "tailable cursor requested on non capped collection ..." each time i want to subscribe to an device. I was able to fix this issue in the databse.js with creating the database collection directly with the "capped: true" property. Without this option it is not possible to use tailable cursors". I don't know if this is related to some changes in mongodb (tested version: 2.6.3). I will make a Pull-Request for this.
Unfortunately, i was not able to fix the issue with NeDB.
Thanks for the heads-up. That bug is on our list (Basecamp #212).
Subscribe should work with MQTT and WebSocket protocols. We are planning to redirect HTTP and CoAP subscriptions to Redis rather than tailing Mongo. This may still be an issue for Raspberry Pis and other smaller devices that may not have enough processing power to run Redis.
Ok, thanks for the info! And for using subscriptions with Mongo, i think i've fixed that with adding the following to database.js:
if(config.mongo){
var mongojs = require('mongojs');
var db = mongojs(config.mongo.databaseUrl);
var devices = db.createCollection('devices' , {capped: true, size:10000,max:1000}, function() {
// do something here
console.log("Devices collection created");
});
var events = db.createCollection('events' , {capped: true, size:10000,max:1000}, function() {
// do something here
console.log("Events collection created");
});
var data = db.createCollection('data' , {capped: true, size:10000,max:1000}, function() {
// do something here
console.log("Data collection created");
});
module.exports = {
devices: db.collection('devices'),
events: db.collection('events'),
data: db.collection('data')
};
}
For now, it is working fine for me (WebSocket subscriptions tested).
Cool. You should only need to cap the events collection.
Hi,
i'm having some issues with the subscription REST-API. I've created some devices and i want to subscribe to one specific device. My curl Call is the following:
curl -X GET "http://localhost:3000/subscribe/0cbd6501-1bca-11e4-834e-331a925ae32b" --header "skynet_auth_uuid: d60670c1-1bbe-11e4-834e-331a925ae32b" --header "skynet_auth_token: 06i10tq9lu7x8ncdixm6uqp0oqykqpvi"
The response from meshblu is: {"code":"InternalError","message":"Object # has no method 'pipe'"} .
Currently, i'm not able to use subscriptions anyway. Websocket are also not working -> Response: timeout.
But the subscriptions should work as the Demo on skynet.im is using subscriptions and working fine.
Any ideas?
=============EDIT====================================================
My first "investigations" are showing that there is an issue with using .pipe() method in "setupHttpRoutes.js". The db-query returns a Cursor-Object (subscribe.js) and this object has only the following structure:
-Cursor -- db: Datastore --- autoload: true --- executor: Executor --- filename: "..." --- inMemoryOnly: false --- indexes: Object --- persistence: Persistence -- execFn: function (err, docs, callback) { -- query: Object --- $or: Array[2] --- timestamp: Object
As you can see, the call "subscribe(req.params.uuid).pipe(foo)" in setupHttpRoutes.js is not possible since there is no such function returned.
Will try to use mongodb, maybe they are returning something