Comments (8)
This library was originally written for mpris-service. The test suite was written to show how I intend to use the library. For other examples, use Github search.
https://github.com/search?p=1&q=dbus-next+language%3AJavaScript+language%3ATypeScript&type=Code
from node-dbus-next.
The bus runs in the background to process dbus messages. If you want it to stop, use bus.disconnect()
when you are done with it and the process should terminate.
from node-dbus-next.
Thanks for the quick reply!
I was looking for something like this, but trying it like this
'use strict'
const dbus = require('dbus-next')
const bus = dbus.systemBus()
bus.disconnect()
throws
Error [ERR_STREAM_WRITE_AFTER_END]: write after end
at Socket.Writable.write (internal/streams/writable.js:292:11)
at /path/to/repo/node_modules/dbus-next/lib/handshake.js:84:16
at Socket.readable (/path/to/repo/node_modules/dbus-next/lib/readline.js:12:11)
at Socket.emit (events.js:315:20)
at emitReadable_ (internal/streams/readable.js:569:12)
at processTicksAndRejections (internal/process/task_queues.js:79:21)
Emitted 'error' event on MessageBus instance at:
at EventEmitter.<anonymous> (/path/to/repo/node_modules/dbus-next/lib/bus.js:159:12)
at EventEmitter.emit (events.js:315:20)
at Socket.<anonymous> (/path/to/repo/node_modules/dbus-next/lib/connection.js:86:10)
at Socket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:106:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'ERR_STREAM_WRITE_AFTER_END'
}
It looks like something is still using that bus? But I have literally just reastarted my computer before I tried this and the example is as simple as I posted it here.
Is it intended that the bus is running forever? I haven't found any info on this in your examples.
Cheers
Fred
from node-dbus-next.
You've run into the unusual case of disconnecting a bus that hasn't connected yet. That's a bug I need to fix.
Is it intended that the bus is running forever?
Yes
from node-dbus-next.
:-D okay. So I have to put some sleep in between to fix this :-D
This actually works :-)
'use strict'
const dbus = require('dbus-next')
const bus = dbus.systemBus()
setTimeout(() => {
bus.disconnect()
}, 1000)
If this is intended, you should mention the need for explicitly calling disconnect() in the docs. I couldn't find anything about it in the examples and even the api docs don't say much about the importance of disconnect. For me it is unexpected that it is intended that bus never terminates and thus needs to be terminated explicitly.
But I'm beginning to understand the reasoning behind it and I think my approach of working with the MessageBus is wrong...
from node-dbus-next.
Is this error I just got in any way related to the fact that dbus-next keeps connections open?
UnhandledPromiseRejectionWarning: DBusError: The maximum number of active connections for UID 1000 has been reached
I'm using nodemon
to auto-restart my application during development. I guess this summed up the number of connections pretty quickly?
Where should I put dbus.disconnect()
? I have a base class DBusObject
from which all other classes inherit. DBusObject
looks like this (very much simplified):
'use strict'
const dbus = require('dbus-next')
class DBusObject {
constructor () {
this.bus = dbus.systemBus()
}
}
module.exports = DBusObject
All classes use this.bus
to interact with the message bus. I don't understand the mechanism of dbus.systemBus()
, I didn't expect to run into any connection limits.
Is there a better approach to do this? Should I connect to the bus and disconnect from it in every method call?
from node-dbus-next.
Creating a bus is a heavyweight operation. You should only have one MessageBus for your whole application.
from node-dbus-next.
So I should make it a global? I actually expected that dbus
already is the global and dbus.systemBus()
just returns the reference... Singleton style or something like that.
Do you know any real application based on dbus-next
that I could look into to see how others are doing it?
from node-dbus-next.
Related Issues (20)
- support TypeScript decorators HOT 2
- Logging errors from event handlers HOT 2
- ProxyObject or Interface went away event missing
- automatic (de)serialization to Variant dicts
- Unable to serialize a{sa{sv}} HOT 2
- no response frpm method
- New release
- Notification example?
- Multiple D-Bus errors occur (application runs fine, however) HOT 1
- Bug: Nodes not added to ProxyObject with root path ("/")
- Vulnerability in `[email protected]` dependency HOT 2
- DBUS_COOKIE_SHA1 auth does not work at all
- Project seems dead HOT 1
- Add access to message in method handler HOT 1
- systemd service HOT 2
- Issue when trying to fetch mpris tracks metadata HOT 1
- Initial signals lost when no previous method call have been made
- Can't bundle it because of `usocket` library HOT 2
- Subscribe to `NameOwnerChanged` by default HOT 3
- Consider using ECMAScript modules? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-dbus-next.