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

Detect proxy in desktop #396

Closed
wants to merge 17 commits into from
Closed

Detect proxy in desktop #396

wants to merge 17 commits into from

Conversation

roll
Copy link
Collaborator

@roll roll commented May 22, 2024


Please make sure that all the checks pass. Please add here any additional information regarding this pull request. It's highly recommended that you link this PR to an issue (please create one if it doesn't exist for this PR)

@roll roll requested review from pdelboca and guergana May 22, 2024 08:48
@roll
Copy link
Collaborator Author

roll commented May 22, 2024

@pdelboca
@guergana
Please take a look.

I don't yet have a proper env with proxy to test; going to do so on Monday

Copy link

cloudflare-workers-and-pages bot commented May 22, 2024

Deploying opendataeditor with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4ac59f7
Status: ✅  Deploy successful!
Preview URL: https://a2b7f170.opendataeditor.pages.dev
Branch Preview URL: https://359-detect-proxy.opendataeditor.pages.dev

View logs

Copy link
Member

@pdelboca pdelboca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @roll .

get-proxy-settings documentation suggest to use native electron support instead: https://www.npmjs.com/package/get-proxy-settings

  • If you are using electron it is recommended to use electron/chromium built in proxy support which is much more advanced.

Have you tried out the native support? https://github.com/electron/electron/blob/main/docs/api/command-line-switches.md#--proxy-serveraddressport

@roll
Copy link
Collaborator Author

roll commented May 27, 2024

@pdelboca
Good finding, I'll try it

@roll
Copy link
Collaborator Author

roll commented Jun 4, 2024

@pdelboca
No, we can't use Electron native detector -- it doesn't provide credentials information (I guess for security reasons). So I guess it's only useful if network calls are made through electron itself.

@pdelboca
@guergana
I tested it, it works for me. Can you please try? I think we might need to make some adjustments later when we see it in the real world to cover hidden edge cases.

@guergana
Copy link
Collaborator

guergana commented Jun 6, 2024

@pdelboca No, we can't use Electron native detector -- it doesn't provide credentials information (I guess for security reasons). So I guess it's only useful if network calls are made through electron itself.

@pdelboca @guergana I tested it, it works for me. Can you please try? I think we might need to make some adjustments later when we see it in the real world to cover hidden edge cases.

@roll which operating system did you test it with? Since this a desktop issue, I think we should try to test in Ubuntu, Windows 10 (version of the user who reported the issue) and Mac.

@roll
Copy link
Collaborator Author

roll commented Jun 10, 2024

@guergana
Currently, it is tested in Ubuntu.

I think there is a gotcha with the get-proxy-settings library as it will definitely won't work in each and every case. My hope that at least it will cover the most of them. In next iteration, we additionaly might need to add an UI for setting up a proxy I suspect

@guergana
Copy link
Collaborator

@roll how did you test the proxy? I tried configuring the default proxy and then tried to make the traffic be caught with postman and I couldn't make it work..

Could you list the steps that you followed? I think I missed something. I will also try to test it in my virtual machine for windows.

@roll
Copy link
Collaborator Author

roll commented Jun 10, 2024

@guergana
I enabled a proxy in Ubuntu and then ensured that pip and python calls were done using it in the env vars (in the electron logs)

@guergana
Copy link
Collaborator

guergana commented Jun 21, 2024

Hello, @roll I am testing the branch in windows 10 pro (with a virtual machine in Ubuntu) and i got the error with the proxy activated:

I am not sure the issue is fixed for Windows 10 (the original operating system of the person who opened the issue).

image

Steps to reproduce the error in Windows 10:

  • configure a proxy on windows 10. (i used this address i found online but I am not sure this works really as a proper proxy).
  • install the app. if you have already installed the app before make sure to delete the .opendataeditor folder before.
  • after install, the app opens and when the startup popup is showing this message appears.

There is nothing related to this error in the logs c:/user/.opendataeditor/logger/main.log

Note: the port 8080 is not set in the address i tested with, I also tried with :80 which exists but is serving the static files 🙈

image

I probably need to find a proper proxy address to test with but I still don't understand why we need a proxy upon loading the app, shouldn't all the packages already be contained in the installation package instead of downloading them on startup?

@@ -18,22 +19,19 @@ export async function ensurePython() {
log.info('[ensurePython]', { message })
}

export async function ensureLibraries() {
export async function ensureLibraries(props: { proxyUrls: types.IProxyUrls }) {
log.info('[ensureLibraries]')

const required = await readRequiredLibraries()
const installed = await readInstalledLibraries()
const missing = required.filter((spec) => !installed.includes(spec))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would there be libraries missing from the installer?

Copy link
Collaborator Author

@roll roll Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It uses the concept of idempotency. The user at any point of time can have:

  • no installed dependencies
  • partially installed dependencies (if a new version of ODE adds a new dependency)
  • partially outdated dependencies (if a new version of ODE bumps a dependency's version)

So the installer calculates the diff and applies missing parts

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The concept sounds elegant, but this means also that if a user downloads the app and then wants to open it for the first time and it's not connected to the internet, it will also throw the error, right? I think it is confusing why some additional libraries need to be installed if the user has already downloaded the binaries. I would switch to a 100% self contained version, this would also shorten the loading time at startup. @roll

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guergana I would also switch of course =)

@roll
Copy link
Collaborator Author

roll commented Jun 24, 2024

I probably need to find a proper proxy address to test with but I still don't understand why we need a proxy upon loading the app, shouldn't all the packages already be contained in the installation package instead of downloading them on startup?

The problem that packaging the python dependencies with tools like py2exe doesn't really work. We tried a few times and never got any reliable results. Of course, it was pretty time-limited attempts maybe with proper timeline it would be possible to achieve.

The second thing is accessing remote files via the server -- it also requires proxy information. It can be eliminated if fetchFile endpoint is implemented directly in Electron though

@guergana
Copy link
Collaborator

I probably need to find a proper proxy address to test with but I still don't understand why we need a proxy upon loading the app, shouldn't all the packages already be contained in the installation package instead of downloading them on startup?

The problem that packaging the python dependencies with tools like py2exe doesn't really work. We tried a few times and never got any reliable results. Of course, it was pretty time-limited attempts maybe with proper timeline it would be possible to achieve.

The second thing is accessing remote files via the server -- it also requires proxy information. It can be eliminated if fetchFile endpoint is implemented directly in Electron though

Since we have more developer time available now probably than in the previous iteration maybe we can try to implement the self contained version? @roll . What do you think about this @pdelboca ?

@pdelboca
Copy link
Member

@guergana I agree with both of you.

When working on #427 I read a little bit about how to package Python applications and as @roll mentioned, sadly all bundling solutions for python do not work as expected.

I do think that we should bundle it since you are right that it doesn't make sense to have errors or need internet connection to open the application. Maybe instead of an executable file we zip/unzip the virtual environment on build/install.

I'll take a look and propose some ideas.

@roll
Copy link
Collaborator Author

roll commented Jul 1, 2024

CLOSED in favour of #446

(parts of this PR can be used to handle #449)

@roll roll closed this Jul 1, 2024
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 this pull request may close these issues.

pip timeout during initialisation in a corporate/public sector environment with HTTP proxy
3 participants