dosyago / dn

💾 dn - offline full-text search and archiving for your Chromium-based browser.
https://localhost:22120
Other
3.78k stars 145 forks source link

On windows browser never connects #119

Closed nicoandmee closed 2 years ago

nicoandmee commented 2 years ago

This is probably a (very?) dumb mistake on my part, but I cannot for the life of me get this running on windows. I can see the browser was launched with the command-line arguments to open port 9222 for remote debugging:

"C:\\Program Files\\BraveSoftware\\Brave-Browser-Beta\\Application\\brave.exe" --remote-debugging-port=9222 --restore-last-session --disk-cache-dir=C:\somewhere --aggressive-cache-discard --no-sandbox http://localhost:22120

But it will timeout trying to reach the browser- as does my curl http://localhost:9222/json/version.

However, if I open powershell and run:

Start-Process "C:\Program Files\BraveSoftware\Brave-Browser-Beta\Application\brave.exe" -ArgumentList -remote-debugging-port=9222

It works, and I'm able to reach the debugging endpoint. Any idea why this might be happening?

On a related note, it might be useful to support connecting to an existing browser rather than always launching a fresh one, by specifying BROWSER_HOST and BROWSER_PORT or something. I work most of the time in WSL2, where I'd prefer to run this project and then connect to my browser running in windows land.

Thanks!

o0101 commented 2 years ago

Thank you for the thorough write up! Let me have a think about this see if I can't come up with some ideas for you.

o0101 commented 2 years ago

I don't think the brave browser can be launched with the current code because it looks for Chrome. I don't think it will look for brave. So I doubt that brave could have been laughed... Which would explain the no connect. I think you need to fiddle with the browser location in order to ensure brave will work.

If brave really was located and launched but doesn't connect, that might be because you were keeping another copy of brave or Chrome open while trying to run this. The way that remote debugging ports work I'm pretty sure is that you can not open multiple browsers at the same time some with remote debugging open some with not, if you're using the same user profile, which you will be if you don't override the profile directory. So to try to fix that make sure you totally shut down any other browsers Chrome or brave that maybe open before you try to run this.

Normally the code looks for browsers and shuts them down but I think it only searches for Chrome browsers so it may not be working with brave and that may be causing the problem. The reason it may work from powershell is maybe using in powershell causes a different profile directory somehow or maybe using in powershell somehow has like a permissions override which is some sort of weird edge case that then makes this chrome behavior about only a single browser with the profile directory and remote debugging port actually work in this case..

So that's my idea for you. Hopefully that works I don't have any more ideas for your part from that. Good luck with this!

Hopefully that gets you far and please I hope you can work it out for yourself from now on. Thanks! ;)