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

Error: Failed to establish a socket connection to proxies #11911

Closed
varunmankal opened this issue Nov 23, 2022 · 24 comments · Fixed by #12266
Closed

Error: Failed to establish a socket connection to proxies #11911

varunmankal opened this issue Nov 23, 2022 · 24 comments · Fixed by #12266
Labels
🤔 needs more info issues that require more info from the author

Comments

@varunmankal
Copy link

Bug Description:

we have some custom plugins deployed in theia 1.27.0. When we launch those plugins, it returns "Failed to establish a socket connection to proxies" error.

However, it was working fine with theia 1.19.0.

  • Operating System: macOS Monterey
  • Theia Version: 1.27.0
@vince-fugnitto vince-fugnitto added the 🤔 needs more info issues that require more info from the author label Nov 23, 2022
@vince-fugnitto
Copy link
Member

@varunmankal thank you for reporting the issue, do you mind providing additional details that can help resolve the problem, it is not actionable at the moment.

  • can you try debugging on your end to see what the problem might be? (given you have the proper environment and plugin to test against)
  • can you share the plugin, or a simple version of it that can reproduce the problem?

@msujew
Copy link
Member

msujew commented Nov 23, 2022

This could be related to my work on proxy support in Theia (see #11043). While it performs some minor changes in the plugin host area, they shouldn't lead to regressions.

@varunmankal
Copy link
Author

@vince-fugnitto sorry, I cannot share the plugin.

But here is the error when I try to debug.

root ERROR [hosted-plugin: 6553] ApplicationInsights:CorrelationIdManager [
Error: Failed to establish a socket connection to proxies: ["https://dc.services.visualstudio.com/api/profiles/AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217/appId"]
at _PacProxyAgent. (/home/node_modules/vscode-proxy-agent/out/agent.js:141:19)
at Generator.next ()
at fulfilled (/home/node_modules/vscode-proxy-agent/out/agent.js:5:58)
]

@msujew
Copy link
Member

msujew commented Nov 23, 2022

Alright, it does seem to be a regression due to my change. My changes introduced the vscode-proxy-agent in question... I'm still a bit confused though, as the normal http module also shouldn't be able to traverse the proxy. Anyway, here are some questions I have in regards to that:

  1. Are you sitting behind a proxy?
  2. If so, are you able to enter the proxy address in the http.proxy user preference? Does that resolve the issue?
  3. Are you using an electron build of Theia? Do you have the same issue with a browser build?

@varunmankal
Copy link
Author

@msujew
No, it is not behind the proxy. we are using theia by importing its packages in package.json. We are playing with it in the browser.

@varunmankal
Copy link
Author

@msujew any thoughts on this ?

@msujew
Copy link
Member

msujew commented Dec 3, 2022

@varunmankal Not really. It'd be great if you could provide us with a reproducible example for this, as I believe no one else has encountered this issue yet.

@varunmankal
Copy link
Author

I see. Let me try to get it.

@varunmankal
Copy link
Author

@msujew quick question. Any thoughts on the value for http proxy support setting in User settings ? Shouldn't that be off by default ?
Screen Shot 2022-12-08 at 3 55 17 PM

If I set it to off, I am seeing no error.

@varunmankal
Copy link
Author

varunmankal commented Dec 9, 2022

@msujew I work for Oracle cloud Infrastructure(OCI). OCI has code editor which is based on theia. As of now, code editor does not support installing external plugins by users and sample extension will require making API calls to OCI services.

@msujew
Copy link
Member

msujew commented Dec 9, 2022

Any thoughts on the value for http proxy support setting in User settings ? Shouldn't that be off by default?

That would result in every request from an extension failing in case the user is sitting behind a proxy. Doesn't sound like a sensible default. If you want to set the default to off you can do so in the preferences of your apps frontend config.

Another interesting thing to know would be if your extension is able to successfully perform the request if installed in vscode, as they are using the exact same package to rewrite externally bound requests.

To reproduce the issue, we don't need/want the full extension, just the code that actually fires the http request. That should be enough (in theory) to reproduce it.

@varunmankal
Copy link
Author

regarding the proxy support setting, makes sense what you have said. In our case, we are not sitting behind the proxy. Even then, we are getting the error “Failed to establish a socket connection to proxies”. However, when we turn it off, we don’t see any error.

We did tried in VSCode, it worked well.

@vince-fugnitto
Copy link
Member

@varunmankal the default preference for http.proxySupport is aligned with vscode:

'http.proxySupport': {
    type: 'string',
    enum: ['off', 'on', 'fallback', 'override'],
    enumDescriptions: [
        localize('proxySupportOff', "Disable proxy support for extensions."),
        localize('proxySupportOn', "Enable proxy support for extensions."),
        localize('proxySupportFallback', "Enable proxy support for extensions, fall back to request options, when no proxy found."),
        localize('proxySupportOverride', "Enable proxy support for extensions, override request options."),
    ],
    default: 'override',
    description: localize('proxySupport', "Use the proxy support for extensions."),
    restricted: true
},

@varunmankal
Copy link
Author

@msujew I have tried using extensions in VS Code. They are working fine. One thing to mention is that we have overridden some of the theia functionality.

I have set http_proxy and https_proxy environment variables and tried extensions in theia blueprint with the flag http proxy support set to off. They still work fine to fetch the info from the internet.

@msujew
Copy link
Member

msujew commented Dec 15, 2022

I have tried using extensions in VS Code. They are working fine.

Alright, that is good to know 👍

I have set http_proxy and https_proxy environment variables

so are you sitting behind a http proxy? You might need to set the proxy url in the http.proxy preference as well, for it to apply in the plugin host. VSCode is able to infer the proxy url using Electron's API, but we are lacking a key component to achieve this.

Anyway, it would be good to have a reproducible example for this. Like I said, no one else has encountered this issue yet.

@varunmankal
Copy link
Author

so are you sitting behind a http proxy? You might need to set the proxy url in the http.proxy preference as well, for it to apply in the plugin host.

I have tried setting proxy url in theia blueprint and set the http proxy support to "off". It still works fine.
what if the API calls from plugins are not using the proxy variables then the proxy support flag might not matter right.

Anyway, it would be good to have a reproducible example for this. Like I said, no one else has encountered this issue yet.

I am not sure if this what you are looking for. I will try my best to provide the code snippets though:

       const client = await getIdentityClient(profile);
       const tenancyId = ext.api.getProfile(profile).getTenancy();

        // Create a request and dependent object(s).
       const listRegionSubscriptionsRequest: identity.requests.ListRegionSubscriptionsRequest = {
           tenancyId: tenancyId
       };
 
       // Send request to the Client.
       subscribedRegions = await client.listRegionSubscriptions(
           listRegionSubscriptionsRequest
       );

The listRegionSubscriptions call is failing with the above mentioned error.

That is basically trying to call the API mentioned here: https://docs.oracle.com/en-us/iaas/api/#/en/identity/20160918/RegionSubscription/ListRegionSubscriptions

@msujew
Copy link
Member

msujew commented Dec 15, 2022

I've taken a closer look at the OCI TypeScript package, and it looks like they're using node-fetch. So they don't seem to do anything weird in that regard.

I've noticed from your initial error description that the PAC agent isn't able to resolve connection to proxy https://dc.services.visualstudio.com/api/profiles/AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217/appId. Are you using Theia on localhost or on some hosted platform solution? Also can you try to install the test extension from #11043 and perform the steps to execute the Hello World Request command? Which notification appears with different values for the http.proxySupport preference?

@erezmus
Copy link
Contributor

erezmus commented Mar 7, 2023

We are also experiencing the same issue in Keil Studio Cloud after upgrading to 1.27. Requests to our build service fail with the same error message. As far as I know we are not running behind a proxy.

Turning the http.proxySupport to off seems to solve the issue.

@msujew
Copy link
Member

msujew commented Mar 7, 2023

@erezmus Can you try the test extension that I've posted above? Does it work as expected?

@erezmus
Copy link
Contributor

erezmus commented Mar 7, 2023

@msujew will have a go

@t1m0thyj
Copy link

t1m0thyj commented Mar 7, 2023

We are experiencing the same problem in Theia 1.34.0 (the version soon to become the community release I think). Installing the Zowe Explorer extension and trying to connect to a mainframe results in the same error message, but setting http.proxySupport to off fixes the issue.

@msujew I've tried the test extension, here are the results with different values for http.proxySupport:

  • off - Request status code: 200
  • on, fallback, override - Request error: Error: Failed to establish a socket connection to proxies: ["https://www.google.com/"]

@msujew
Copy link
Member

msujew commented Mar 7, 2023

@t1m0thyj Thanks for confirming the issue! I can actually reproduce this as well now (on every environment). I'll investigate this further.

@t1m0thyj
Copy link

@msujew Thanks for opening the PR ❤️ Any idea when the fix will be released, and whether it will make it into the 1.34.x community release? 🙏 In the meantime, my team will document the workaround of setting http.proxySupport to off.

@msujew
Copy link
Member

msujew commented Mar 28, 2023

@t1m0thyj I don't know whether the release team is planning to perform another community release update. However, the PR has now been merged and will be included in this month's release (1.36.0 on Thursday) which will become the community release 2023-5 at the end of April.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤔 needs more info issues that require more info from the author
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants