Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows <10 only?] System.Exception: No unused port found! #301

Open
uncajesse opened this issue Jun 28, 2021 · 16 comments · May be fixed by #313
Open

[Windows <10 only?] System.Exception: No unused port found! #301

uncajesse opened this issue Jun 28, 2021 · 16 comments · May be fixed by #313

Comments

@uncajesse
Copy link

uncajesse commented Jun 28, 2021

KeePass 2.48.1
KeyAnywhere 2.0.3
Windows 7 x64

In KeyAnywhere Settings, Accounts,

When I attempt to add an account of type Dropbox, Dropbox-Restricted, Google Drive, HiDrive, and OneDrive, there is an error message "System.Exception: No unused port found!"

There is also a hang for a few seconds before the error message displays, for all of those except the two Dropbox options. The two Dropbox options instantly display the error.

Thanks !!

error.txt

@onuruslu
Copy link

onuruslu commented Jul 1, 2021

Same happens to me

@Kyrodan
Copy link
Owner

Kyrodan commented Jul 2, 2021 via email

@onuruslu
Copy link

onuruslu commented Jul 3, 2021

Which Windows Version are you using? Do you have any user or firewall restrictions? Could you try to start KeePass with admin/elevated permissions? The ports are only required for authentication. Once authenticated you can use KeeAnywhere without any elevated permissions. Am Fr., 2. Juli 2021 um 00:18 Uhr schrieb Onur Uslu < @.***>:

Same happens to me — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#301 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACWW2SN2HMMY45JCVONOK3TVTSTFANCNFSM47ODOLWA .

Hi @Kyrodan,

I'm so sorry for the late response.

  • Which Windows Version are you using?
    I'm using Windows 8.1.

  • Do you have any user or firewall restrictions?
    I'm the admin user on the computer. I don't have any restrictions. I'm getting the error even if I deactivate all protection functionalities of my antivirus (including antimalware, firewall, etc.).

  • Could you try to start KeePass with admin/elevated permissions?
    I started using the "Run as administrator" button on the context menu, but it did not solve the problem.

By the way, I'm using "Keepass 2.47" and "KeeAnywhere 2.0.3".

Thank you

@JNavas2
Copy link

JNavas2 commented Jul 19, 2021

I confirm that 2.0.3 fails authentication (on Windows 8.1) unless KeePass is Run as Administrator.
This is a serious issue that urgently needs to be fixed. Otherwise I will have to stop recommending it.
Thank you.

@Kyrodan
Copy link
Owner

Kyrodan commented Jul 19, 2021 via email

@JNavas2
Copy link

JNavas2 commented Jul 19, 2021

@Kyrodan

Please don't presume to tell me what to do.

I'm an experienced, expert software professional with both FOSS and non-FOSS to my credit. When I offer software to the public, I make a commitment, because those who use it deserve my best work and to not be harmed. Making it free does not relieve me of that responsibility. You may not care about your reputation, but I care about mine, deeply.

When I recommend software to colleagues, clients, and the public, I likewise put my reputation on the line, because they expect me to carefully vet my recommendations and to stand behind them. That's why I cannot recommend unsupported software.

Lastly, if you do want help, then you might not want to start with criticism.

"If you can't stand the heat, get out of the kitchen."

@Kyrodan
Copy link
Owner

Kyrodan commented Jul 20, 2021

@JNavas2

I'm an experienced, expert software professional with both FOSS and non-FOSS to my credit.

If you are a FOSS-Developer, I'm sure you wouldn't discuss topics the way you do. Take a look to your reported issues in other repositories, it's often the same. Maybe you have FOSS activities, maybe not - none a filed in your GitHub Profile.

When I offer software to the public, I make a commitment, because those who use it deserve my best work and to not be harmed. Making it free does not relieve me of that responsibility. You may not care about your reputation, but I care about mine, deeply.

You can do it that way in your projects. But that's not my understanding and I always make this clear.

That's why I cannot recommend unsupported software.

Come on, stop dreaming! In FOSS there is no support you can rely on unless you pay for it or a company is supporting the project. I'm a single developer - like many others - that is doing it in their spare time. Help is appreciated but your kind of comments are clearly unwanted by me.

I think we should stop this discussion here, we put all our arguments in this issue.

If you find a proper way to support Windows 8.1, please file a PR. Otherwise I don't think this issue will be fixed by me: I don't have the proper ressources for this.

@Kyrodan Kyrodan changed the title System.Exception: No unused port found! [Windows <10 only?] System.Exception: No unused port found! Jul 20, 2021
@Kyrodan
Copy link
Owner

Kyrodan commented Jul 21, 2021

Can someone with this problem please post the output of
netsh int ipv4 show dynamicport tcp

On windows 10 it looks like

Protokoll tcp Dynamischer Portbereich
---------------------------------
Startport      : 49152
Anzahl von Ports : 16384

@onuruslu
Copy link

Can someone with this problem please post the output of
netsh int ipv4 show dynamicport tcp

On windows 10 it looks like

Protokoll tcp Dynamischer Portbereich
---------------------------------
Startport      : 49152
Anzahl von Ports : 16384

@Kyrodan It looks like the same on Windows 8.1

Protocol tcp Dynamic Port Range
---------------------------------
Start Port      : 49152
Number of Ports : 16384

Note: When I see the new messages in the issue, I tried to use the "Run as administrator" button again. It worked, and I don't get errors anymore. I have no idea why it didn't work before.

@JNavas2
Copy link

JNavas2 commented Jul 23, 2021

@Kyrodan
I don't appreciate your comments, and as I warned, I don't use or recommend unsupported software, so I'm not going to invest any more time here. We'll just have to agree to disagree (on pretty much all counts it seems). But I do appreciate you pushing me to step back and take a hard look at why I was using a plugin in the first place.

The basic reason is that KeePass lacks cloud support, but, as the saying goes, "there's more than one way to skin a cat," and virtual drive is a better way (for a number of reasons) to access the cloud. Since I use Google Drive, which has virtual drive capability, it was a no brainer: I simply moved my KeePass files from OneDrive to Google Drive, where KeePass now accesses them via virtual drive without any plugin.

I also use Keepass2Android, and it has cloud support, so that was just a simple reconfiguration.

KeePass is now working better than before, with no plugin needed.
So I thank you, and bid you a heartfelt farewell.
(Feel free to have the last word.)

p.s. For those who prefer to use a cloud service other than Google Drive, it's easiest to use one with virtual drive capability, but you can otherwise use Mountain Duck. (It's also possible to use OneDrive with Windows native Network Drive functionality, but it's a hassle to set up properly.)

@courrier1
Copy link

KeePass 2.48.1
KeyAnywhere 2.0.3
Windows 7 x64

Same issue, but if I run it as Administrator, it works fine.

Can someone with this problem please post the output of
netsh int ipv4 show dynamicport tcp

Windows 7 x64:

Protocol tcp Dynamic Port Range
---------------------------------
Start Port      : 49152
Number of Ports : 16384

@Jackabomb
Copy link

Hi, I too am having this issue. In my case, with Google Drive.

KeePass 2.48.1
KeeAnywhere 2.0.3

Windows 7 x64

Protocol tcp Dynamic Port Range
---------------------------------
Start Port      : 1025
Number of Ports : 64510

For me, starting KeePass as administrator got it to work, but that defeats the point. When I launched KeePass as a regular user, the account was missing from the account list again. This makes sense; presumably the KeeAnywhere account details are stored in the user's AppData.

Interestingly, this very same laptop was previously using KeeAnywhere 2.0.3 successfully. This didn't just appear when I updated.
To my knowledge there's no user limitations or firewall restrictions (that I've put in place) that would cause a problem.
Temporarily disabling antivirus did not help.

Here's the full error message details, if it's helpful.
ka error output.txt

I'm afraid I'm not much of a C# programmer, but I would like to get this fixed and I'm happy to help however I can. Please let me know anything I can do.

@finejustice
Copy link

finejustice commented Aug 27, 2021

@Kyrodan
Could you test localhost, not 127.0.0.1?

// KeeAnywhere.OAuth2.OidcSystemBrowser
        private static string CreateRedirectUri(int port)
        {
            return "http://localhost:" + port + "/";
        }

It sounds ridiculous, however windows denies http://127.0.0.1:49215/ without administrator privileges but it allows http://localhost:49215/.

attached gist to test this problem. paste into test project.
https://gist.github.com/finejustice/908e63d5b7e57cf69039f10ad21d8095

tested in Windows 7 x64.

@Jackabomb
Copy link

@finejustice @Kyrodan It works! I tried changing the Oidc URI to localhost and it fixed the problem at least for Google Drive on Windows 7 x64.

More background on this bug:
It seems like this might be due to an undocumented bug feature in HttpListener (actually down in HTTP.sys).
You have to "reserve" the URL you intend to listen on if you're not Admin, which is even more problematic for dynamic ports. Google turns up a whole family of results. One random comment suggests that @finejustice 's workaround succeeds because "localhost" is somehow treated differently. Seems like basing off of something called tcplistener can also avoid the problem?

Completely Unanswered Questions

  • Why doesn't this appear to matter on Win10?
  • Why was my laptop working previously?
    It could be instructive to try netsh http show urlacl to view these "reservations" on different systems that have and don't have this issue.

@Jackabomb
Copy link

I just tried it in Windows 10 and it seems to work here too.

@ansverrr
Copy link

ansverrr commented Jun 1, 2022

Faced this issue too. In my case, with Google Drive

All works just fine on my home laptop with Win 11, but it doesn't on work desktop with Win 8.1.

Win 8.1, KeePass 2.51.1, KeeAnywhere 2.0.3
"Run as administrator" has solved that problem. Saved settings to KeePass configuration just in case. But I do wait for fix of this bug, moreover the solution is one-line change (thx to Jackabomb).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants