zazuko / vscode-sparql-notebook

Visual Studio Code SPARQL Notebook Extension
https://marketplace.visualstudio.com/items?itemName=Zazuko.sparql-notebook
Other
25 stars 8 forks source link

Use SPARQL Notebook behind proxy #39

Open metaodi opened 1 year ago

metaodi commented 1 year ago

When using this extension and try to connect to an endpoint I get the following error:

Error: Failed to connect to "schema admin": Cannot set headers after they are sent to the client

I suspect this is because I'm behind a proxy at my workplace. Are the HTTPS_PROXY, HTTP_PROXY etc. env variables respected by this extension? Or any other advice, how to get the connection to work?

BenjaminHofstetter commented 1 year ago

Short answer: it not possible.

Long answer: Extensions don't benefit yet from the same proxy support that VS Code supports. You can follow this issue's development in GitHub.

I think it's possible to read the env HTTPS_PROXY or, HTTP_PROXY but then I have to implement it. And then what is about Authentication, NTLM, Kerberos or, (I need) Client SSL Certificate Support. This is really something VSCode should solve and not every extension.

MathiasVDA commented 1 year ago

Hello, I just want to say that I'm also behind a corporates proxy (with login) and for me the http_proxy environment variables work. I'm pointing the variables to a service called px that takes care of authentication for me (I don't need to change the variables nor the px configuration when I update my password).

adbdkb commented 1 year ago

How do you point http_proxy environment variables to the px service? Can you put the command here? I am running into same issue with SQLTools / Athena driver and wanted to try this.

MathiasVDA commented 1 year ago

well it's just setting the variable http_proxy and https_proxy to http://localhost:3128 image

I then have 2 bat scripts, one for when I'm connected to the enterpirse network and I need to pass through the corporate proxy:

cd /D "%~dp0"
px --quit
px --pac=http://route.to.our/proxy.pac --gateway --noproxy= --debug --verbose --save
START /B px
pause 

and one for when I don't need the corporate proxy:

cd /D "%~dp0"
px --quit
px --pac= --gateway --noproxy=*.*.*.* --save
START /B px
pause

px takes care of the authentication for me

for reference, this is the px.ini file (some settings are overwritten depending on the bat script I launch:

[proxy]
pac = http://route.to.our/proxy.pac
port = 3128
listen = 
allow = *.*.*.*
gateway = 1
hostonly = 0
noproxy = 
useragent = 
server = 
username = 
auth = 

[settings]
workers = 2
threads = 5
idle = 30
socktimeout = 20.0
proxyreload = 60
foreground = 0
log = 0
adbdkb commented 1 year ago

Thank you @VBP8501 - My problem is - I am on a corporate VDI. So, I have to have proxy for internet connectivity all the time, even for making connection with AWS from the VDI. How can I use px only for SQLTools extension from VSCode, but have the proxy available for other work?

MathiasVDA commented 1 year ago

@adbdkb px will still use your corporate proxy if you configure it correctly. So everything will still work as before. Unfortunately I have no experience with SQLTools and px.

adbdkb commented 1 year ago

@VBP8501 - I am not familiar with creating pac file. I had thought it is auto-generated, but seems like we have to manually create one. Can you put a sample pac file here so I can use it when on network ?

From wiki, this is an example

function FindProxyForURL (url, host) { return 'PROXY proxy.example.com:8080; DIRECT'; }

Will it work, if I put my proxy above and leave everything as is? But then, where the localhost:3128 come into play?

Thanks

MathiasVDA commented 1 year ago

I use a pac file since my company works with one. Wether your company uses one or not can be found in the windows settings: image

A pac file typically specifies the proxy address depending on the host you are trying to reach. My company wants to load balance depending on the domain (not saying this is a smart thing). But it can also give you information for where not to use a proxy, for example for local addresses like 192.168..

If you don't have a pac file, then don't use that option in px and just set the proxy address

  --proxy=  --server=  proxy:server= in INI file
  NTLM server(s) to connect through. IP:port, hostname:port
    Multiple proxies can be specified comma separated. Px will iterate through
    and use the one that works

I'd advise to read the manual: https://github.com/genotrance/px

adbdkb commented 1 year ago

I did have a look at that manual. I tried px --install, but then it did not use the proxy that I had set. So I did a px --uninstall. I think what I need is just use the px proxy only when using VSCode, but can't get that to work. Will try to look at the flags once again. But my question is - do I need to do a px --install to use it ?

MathiasVDA commented 1 year ago

No you don't need to do px install. You just need to launch px with the proper settings and configure it as your proxy in your application