Skip to content

No exception thrown if tor port binding fails. #6

@mattcollier

Description

@mattcollier

if one executes two instances of the following code:

var dataDir = __dirname + '/demo-data';
var thsBuilder = require('ths');
var ths = new thsBuilder(dataDir);

ths.start(false, function() {
  console.log('ths has started.');
});

The second instance fails without any error or exception. By enabling some logging on line 396:

console.log('[tor Process] ', data.toString('utf8')); 

I can see the cause of the issue:

[tor Process]  Mar 24 09:44:30.437 [notice] Tor v0.2.5.10 (git-43a5f3d91e726291) running on Linux with Libevent 2.0.21-stable, OpenSSL 1.0.1k and Zlib 1.2.8.
Mar 24 09:44:30.437 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Mar 24 09:44:30.437 [notice] Read configuration file "/home/matt/thstiming/demo-data/ths-data/torrc".
[tor Process]  Mar 24 09:44:30.441 [notice] Opening Socks listener on 127.0.0.1:9999
Mar 24 09:44:30.441 [warn] Could not bind to 127.0.0.1:9999: Address already in use. Is Tor already running?
Mar 24 09:44:30.441 [notice] Opening Control listener on 127.0.0.1:9998
Mar 24 09:44:30.441 [warn] Could not bind to 127.0.0.1:9998: Address already in use. Is Tor already running?
Mar 24 09:44:30.441 [warn] Failed to parse/validate config: Failed to bind one of the listener ports.
Mar 24 09:44:30.441 [err] Reading config failed--see warnings above.

During development, I have encountered zombie tor processes which cause unexpected behavior. Catching this type of error would be helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions