question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

spawn/spawnAndWait fails to open socket

See original GitHub issue

Issue Checklist

  • I’m using the library programmatically

Library version

0.0.13

Runtime

Linux, Chrome Version 100.0.4896.127 (Official Build) (64-bit)

Device

DJI FPV goggles V2

Describe the bug

When trying to spawn a process:

const device = await AdbWebUsbBackend.requestDevice();
const streams = await device.connect();
const adb = await Adb.authenticate(streams, credentialStore, undefined);
const result = await adb.subprocess.spawnAndWait(["ls"]);

I get the following error (same thing with spawn and spawnAndWaitLegacy):

Error: Socket open failed
    at AdbPacketDispatcher.handleClose (dispatcher.ts:129:1)
    at Object.write (dispatcher.ts:67:1)
    at g (webidl.ts:78:1)
    at S (webidl.ts:88:1)
    at Object.write (underlying-sink.ts:71:1)
    at WritableStreamDefaultController.i [as _writeAlgorithm] (writable-stream.ts:1114:1)
    at writable-stream.ts:544:1
    at Br (writable-stream.ts:1202:1)
    at writable-stream.ts:1171:1
    at Cr (writable-stream.ts:917:1)
    at Object._chunkSteps (pipe.ts:117:1)
    at G (default-reader.ts:51:1)
    at at (default-controller.ts:251:1)
    at ReadableStreamDefaultController.enqueue (default-controller.ts:91:1)
    at Object.pull (transform.ts:345:1)

This seems to be specific on my device, I tried with a phone and it works. Interestingly enough I can get a shell process no problem:

const device = await AdbWebUsbBackend.requestDevice();
const streams = await device.connect();
const adb = await Adb.authenticate(streams, credentialStore, undefined);
const socket = await adb.subprocess.shell();
const writer = socket.stdin.getWriter();
socket.stdout.pipeTo(new WritableStream({
  write: (chunk) => {
    console.log(decodeUtf8(chunk));
  }
}));

I would really love to be able to spawn a process though and get output and exit codes. Let me know which information you need to further debug this

Steps to reproduce

const device = await AdbWebUsbBackend.requestDevice();
const streams = await device.connect();
const adb = await Adb.authenticate(streams, credentialStore, undefined);
const result = await adb.subprocess.spawnAndWait(["ls"]);

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
yume-chancommented, Apr 30, 2022

Version 0.0.14 released with the fix.

1reaction
yume-chancommented, Apr 28, 2022

Checked the source code of Android 6 and found out it doesn’t support the command format I use.

You can manually patch your node_modules/@yume-chan/adb/esm/commands/subprocess/protocols/none.js line 18 to give it a try.

- return new AdbSubprocessNoneProtocol(await adb.createSocket(`shell,raw:${command}`));
+ return new AdbSubprocessNoneProtocol(await adb.createSocket(`exec:${command}`));
Read more comments on GitHub >

github_iconTop Results From Across the Web

"Could not open socket" - Stack Overflow
It just means that somewhere between your server and the recaptcha server, there's a network communications problem that prevents the socket ...
Read more >
SERVER PROCESS DOES NOT COMMUNICATE STATUS.
The server fails to open a socket on the localhost, which it uses to communicate status to the launching process. This problem can...
Read more >
H29+ won't start with permission error to open ICMP socket
The opennms user requires permission to use a datagram socket to be able to send ICMP (ping) messages. By default, a user doesn't...
Read more >
Windows Sockets Error Codes (Winsock2.h) - Win32 apps
Too many open files. Too many open sockets. Each implementation may have a maximum number of socket handles available, either globally, per ...
Read more >
Error: Cannot open socket for listening, -102 - Esri Support
In ArcSDE 9.3 for SQL Server, when starting an ArcSDE service, the following error displays: "Cannot open socket for listening, -102" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found