Opened 14 months ago

Last modified 11 days ago

#20890 assigned defect

Could not connect to Tor control port

Reported by: torrc591 Owned by: brade
Priority: Very High Milestone:
Component: Applications/Tor Browser Version:
Severity: Critical Keywords:
Cc: mcs, tbb-team Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

I am on Windows 8.1 x64, not running an anti-virus app, or the firewall.
I have Tor 6.0.7
it was working fine, but something I have error "Could not connect to Tor control port"
Tried install new Tor in another folder and fine work, but after some time I get the same error message.
I tried
Start a Command Prompt (cmd.exe) and cd to Tor Browser\Browser (the folder that contains firefox.exe).
At the command prompt, type: firefox -console -jsconsole

And nothing. Nothing error logs, but Tor not running and I get same error message.

After shutdown system Tor fine work. But after some time, after close and reopen Tor window I get same error - "could not connect to Tor control port"

Child Tickets

Attachments (2)

TimeoutFailed.txt (4.8 KB) - added by GreenReaper 11 days ago.
Timeout failure
TimeoutOK.txt (8.2 KB) - added by GreenReaper 11 days ago.
Timeout OK (third time lucky)

Download all attachments as: .zip

Change History (9)

comment:1 Changed 14 months ago by cypherpunks

After shutdown system Tor fine work. But after some time, after close and reopen Tor window I get same error - "could not connect to Tor control port"

Check by task manager if tor.exe were terminated.

comment:2 Changed 7 months ago by TimeForGoToBed

I am having the same issue (or a closely related one). I see there are a number of tickets about this bug, but none of them provided any help for my situation. I am running Tor Browser 7.0.1 on Windows 7 Starter (which is 32-bit). I tried downgrading to 6.0.5, but that didn't help. Everything works fine on my Windows 7 Professional 64-bit system.

On my Windows 7 Starter system, Tor always works after a fresh install, but never works again after the first run. Rebooting does not help, in my case, only reinstalling (or deleting the install directory and then copying over a backup saved before the first run). This 32-bit system is a relatively slow netbook from a number of years ago, so it may be the hardcoded 30-second timeout that's causing it to get the Tor Launcher "Could not connect to Tor Control port." popup. It takes over 30 seconds on this system between launching the executable (on 2nd and subsequent runs) and the Tor Status window even appearing (and the progress bar never makes any progress before it fails). That timeout value should really be controllable via an extensions.torbutton.* preference and/or an environment variable. As with the OP, disabling Windows firewall and antivirus doesn't help. Also, hitting "Open Settings" after the failure popup results in a Tor Network Settings window that just displays a permanent "Waiting for Tor to start..." message. After a fresh install, that message only appears for a few seconds, and then after pressing "Connect", the connection bar generally starts making progress immediately.

Oddly, if I do a 'telnet localhost 9151' before (or after) the "Could not connect to Tor Control port." popup appears, I am able to successfully connect to the port (though I didn't try anything beyond connecting). I tried using the extensions.torlauncher.prompt_at_startup preference and also the TOR_FORCE_NET_CONFIG=1 environment variable to get it to start with the Tor Network Settings dialog after the first run, in the hopes that the explicit wait for Tor to start would work around the 30-second timeout, but strangely, in that situation, too, I just get a permanent "Waiting for Tor to start..." message. I also tried reverting a few different preferences / state files to their pre-first-run versions, but none of the ones I tried helped.

I have confirmed that tor.exe and firefox.exe are getting properly shut down between runs. My system clock is also set accurately. I have tried installing in multiple different (NTFS) locations, including the default of my Desktop, to rule out permissions issues. As with the OP, when I start the Tor Browser firefox.exe (I also have the normal Firefox on this system, and it works fine) with -console -jsconsole, I get no console output (do I need to change some log level to be more verbose or something?). There are a couple of add-ons I need to use with Tor Browser (they do not change my browser signature, and I believe their authors to be trustworthy), but since they require restarting to use, I can never use them, since I need to start with a fresh install every time. Note that selecting those for installation is not what's causing this failure, though -- it fails on the second run and thereafter regardless of whether I install any add-ons on the first run (and regardless of whether I make any settings changes). Though I've tried just about everything else, I have not attempted to run Tor Browser as an Administrator, so please let me know if trying that would help with debugging this.

Last edited 7 months ago by TimeForGoToBed (previous) (diff)

comment:3 Changed 7 months ago by gk

Status: newneeds_information

TimeForGoToBed thanks for this comment. Let's try to figure out what is going on in your case. I assume you are not getting any logs or notices that you can copy something to the clipboard? If that's the case then we might need to pursue a different road:

Could you download the expert bundle and replace the tor.exe that comes with Tor Browser with the one that's in the expert bundle? The location for the 0.3.0.8-based one is:

https://dist.torproject.org/torbrowser/7.0.1/tor-win32-0.3.0.8.zip
https://dist.torproject.org/torbrowser/7.0.1/tor-win32-0.3.0.8.zip.asc

You find the tor.exe in your Tor Browser in torbrowser_base_dir\Browser\TorBrowser\Tor. Starting with the tor.exe from the expert bundle should pop up a console with messages from tor. Could you do that before you first start a freshly installed Tor Browser so that we can compare both logs (please add them to this ticket), one you get from a working Tor Browser and one from a broken one.

comment:4 in reply to:  2 Changed 7 months ago by gk

Replying to TimeForGoToBed:

As with the OP, when I start the Tor Browser firefox.exe (I also have the normal Firefox on this system, and it works fine) with -console -jsconsole, I get no console output (do I need to change some log level to be more verbose or something?).

Yes. You need to set extensions.torlauncher.logmethod and extensions.torbutton.logmethod to 0 and ideally at least extensions.torlauncher.loglevel to 0 as well. You can do that in your about:config. If I (re)-start Tor Browser now on the command line with firefox.exe -console a console window pops up with Tor Launcher debug output. Please add that as well to this ticket.

Changed 11 days ago by GreenReaper

Attachment: TimeoutFailed.txt added

Timeout failure

Changed 11 days ago by GreenReaper

Attachment: TimeoutOK.txt added

Timeout OK (third time lucky)

comment:6 Changed 11 days ago by GreenReaper

Owner: changed from tbb-team to brade
Status: needs_informationassigned

The issue in my case is intermittent and subsequent launches may or may succeed. More often than not, they do not. Attached are logs from both cases.

When it fails, it does so on the third attempt to AUTHENTICATE (the first one seem to be refused quickly, while the second times out; the question is if that repeats):
TorLauncher NOTE: failed to open authenticated connection: [Exception... "Component returned failure code: 0x804b000e (NS_ERROR_NET_TIMEOUT) [nsIBinaryInputStream.readBytes]" nsresult: "0x804b000e (NS_ERROR_NET_TIMEOUT)"

I suspect seeds of this issue were introduced early on when a 15-second timeout was added:
https://gitweb.torproject.org/tor-launcher.git/commit/src/components/tl-protocol.js?id=bded277453e87892eca5a2834ecce079accf88a9

TorSendCommand tries a few times according to the code, but eventually it's game over. This is an issue for slow devices in general, but attempts to increase Tor security may also have increased its startup time.

My device is a Lenovo x120e with a 2011 dual-core mobile AMD Fusion CPU (E-350). It is entirely possible that insufficient time is being given for the launch, especially if other tasks are running in the background. A "good" launch is 30 seconds, and Tor.exe takes up the entirety of one core for at least 20 of those.

As for why it tends to work for the first launch, perhaps this is because according to
https://gitweb.torproject.org/tor-launcher.git/tree/src/components/tl-process.js
// Start tor with networking disabled if first run

Alternatively, maybe addons are installed or updated, or the necessary files are already in memory/cache, and not fragmented; or Tor has less state cached and so less to look up. I think you need to try running it in combination with other high-CPU tasks on a limited number of slow cores and see how it falls over.

I suspect #24776 is the same issue; Windows 7 Starter Edition is restricted to low-class devices.

comment:7 Changed 11 days ago by mcs

Cc: mcs tbb-team added
Note: See TracTickets for help on using tickets.