Closed Bojack92160 closed 2 years ago
You are using the ws
package and not the native WebSocket. So this is not a browser API but a Node.js thing (different HTTP stack from the renderer/browser). It can be proxied according to their docs https://www.npmjs.com/package/ws#how-to-connect-via-a-proxy but you shouldn't need that package at all.
thanks for the answer, this explain this behaviour
Preflight Checklist
Electron Version
18.3.0
What operating system are you using?
Windows
Operating System Version
Windows 10
What arch are you using?
x64
Last Known Working Electron version
don't know
Expected Behavior
I would like to make my websocket connection (as a client) go through a proxy. For that, I create my websocket in a browser window, and use setProxy on the window.
When I use setProxy on the session of a browser window, I expect it to proxify all connections.
Actual Behavior
The websocket is well opened but does not go through the proxy. In fact, the 'login' event is not even called. I have tried to use webContents.session.forceReloadProxyConfig() wihtout success. If I use loadUrl to go for example on 'https://whatismyipaddress.com/', this request go though the proxy, and the login event is called
Testcase Gist URL
No response
Additional Information
Environment versions: node 16.15.1 ws 8.6.0
Code: Here is my code to reproduce:
In the main process:
The render process:
index.html:
renderWs.js :