Comments (2)
Here's how I would listen to / create tunnels for devices:
var listener = usbmux.createListener()
.on('attached', function(udid) {
console.log('Device attached: %s', udid);
createSocket(udid);
})
.on('detached', function(udid) {
console.log('Device detached: %s', udid);
})
.on('error', function(err) {
console.log(err);
});
function createSocket(udid) {
usbmux.getTunnel(10022, {udid: udid}) // <-- with udid
.then(function(tunnel) {
console.log('Tunnel created on %s', udid);
tunnel.write('hello');
})
.catch(function(err) {
console.log(err);
});
}
Are you doing something similar? You can enable debugging and see if something is going obviously wrong with the usbmuxd handshake. Set an environment variable export DEBUG=usbmux:*
to enable that output.
There was also problem with the library and linux/libimobiledevice which could be it.
The usbmuxd that comes with libimobiledevice only gets started when a device is attached and stops as soon as the last device is removed. It's a different behavior that osx/windows where it always runs in the background. I added in a filesystem watcher to check for the usbmuxd.pid
file on linux, and it seems to work ok for me, even if it is pretty hacky. You can check it out and see it solves it. If its works ok for you too I think I'll call it good and merge.
You can install the github branch with npm with
npm install DeMille/node-usbmux#ubuntu
from node-usbmux.
I'm doing quite similar like that one you wrote.
Instead of watching device attach/detach with usbmux.createListener()
I'm using node-usb-detection, this also returns the udid
of the connected device.
After then I'm creating the tunnel as you said earlier using usbmux.getTunnel(port, {udid: udid})
What I'm doing is that,
function createSocket(device) {
usbmux.getTunnel(10022, {udid: device.udid}).then(function(tunnel) {
device.tunnel = tunnel;
})
.catch(function(err) {
console.log(err);
});
}
In other function I'm using device.tunnel
to listen or write from the socket. Till now this is totally fine. Once I detach the device, and attach again, the same function createSocket(device)
get called again, this time I'm getting this error,
Is the socket is not closing when detaching the device?
I'm gonna try with the specific branch, I'll let you know any progress. But please tell me if this approach is ok or I need to change something.
from node-usbmux.
Related Issues (5)
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-usbmux.