adbkit icon indicating copy to clipboard operation
adbkit copied to clipboard

client.trackDevices() occur ECONNRESET error after unplug, then plug in phone again.

Open ghost opened this issue 7 years ago • 8 comments

My source code like bellow: var adb = require('adbkit') var client = adb.createClient('localhost', '5037', adbbinarytool )

client.trackDevices() .then(function(tracker) { tracker.on('add', function(device) { console.log('Device %s was plugged in', device.id) }) tracker.on('remove', function(device) { console.log('Device %s was unplugged', device.id) }) tracker.on('end', function() { console.log('Tracking stopped') }) }) .catch(function(err) { console.error('Something went wrong:', err.stack) })

Step1: Plug in a phone; Step2: Start above code project; Step3: Log 'Device %s was plugged in' is shown on console; Step4: Unplug the phone, log Device %s was unplugged is shown on console; Step5: Plugin the phone again, error occurs:

Not 100% issue, but often.

read ECONNRESET: Error: read ECONNRESET at exports._errnoException (util.js:1050:11) at TCP.onread (net.js:581:26)

ghost avatar May 08 '18 07:05 ghost

Supplement:

  1. Huawei Phones;
  2. Nodejs version: v8.9.3
  3. Win7 64bits.

ghost avatar May 08 '18 07:05 ghost

Sounds like an issue with ADB itself. Seems to me like it’s dying when that happens.

sorccu avatar May 08 '18 07:05 sorccu

Hi Sorccu, yes, the adb client is dead when this error occurs. The adb version: Android Debug Bridge version 1.0.39 Version 27.0.0-4455170.

By the way, I run adbkit in Eelectron process.

ghost avatar May 09 '18 02:05 ghost

Sorry, correct the version information, it is "Revision 3db08f2c6889-android" in fact.

ghost avatar May 09 '18 02:05 ghost

You should try to figure out why your adb process dies. Perhaps the ADB_TRACE environment variable will help.

sorccu avatar May 09 '18 02:05 sorccu

Hi Sorccu, there is no ADB_TRACE var in my environment when this error occurs.

ghost avatar May 09 '18 03:05 ghost

That's not what I meant. Start your adb with ADB_TRACE (Google the value you should use) and try to figure out why it's dying. I really don't think this is an issue with adbkit.

sorccu avatar May 09 '18 03:05 sorccu

I also had the same problem on window. Error: read ECONNRESET at TCP.onStreamRead (internal/stream_base_commons.js:209:20) Emitted 'error' event on Connection instance at: at Connection._handleError (C:\Program Files\xxxxxx\node_modules\adbkit\lib\adb\connection.js:99:12) at Socket. (C:\Program Files\xxxxxx\node_modules\adbkit\lib\adb\connection.js:53:22) at Socket.emit (events.js:327:22)

My opinion is even tough adb server is killed, electron app shoud be alive. Can you have any idea to save electron app even if adb server is killed??

slugger941 avatar Mar 16 '22 00:03 slugger941