@@ -4,11 +4,14 @@ namespace ElectronNET.API;
44
55using System ;
66using System . Collections . Generic ;
7+ using System . Net ;
8+ using System . Net . Http ;
79using System . Threading ;
810using System . Threading . Tasks ;
911using ElectronNET . API . Serialization ;
1012using Microsoft . Extensions . DependencyInjection ;
1113using SocketIOClient ;
14+ using SocketIOClient . Protocol . WebSocket ;
1215using SocketIO = SocketIOClient . SocketIO ;
1316using SocketIOOptions = SocketIOClient . SocketIOOptions ;
1417
@@ -39,11 +42,29 @@ public SocketIOConnection(string uri, string authorization, Action<IServiceColle
3942 _socket = new SocketIO ( new Uri ( uri ) , opts , services =>
4043 {
4144 services . AddSystemTextJson ( ElectronJson . Options ) ;
45+
46+ // Electron.NET always connects to http://localhost:{port} - a system/corporate
47+ // proxy is never meaningful here and can break the connection. Force "no proxy"
48+ // by default; apps can still override via ConfigureElectronSocketIO if they
49+ // genuinely need one (e.g. a local debugging proxy).
50+ services . AddSingleton < IWebProxy , NoProxy > ( ) ;
51+ services . AddSingleton ( sp => new WebSocketOptions { Proxy = sp . GetRequiredService < IWebProxy > ( ) } ) ;
52+ services . AddSingleton ( _ => new HttpClient ( new HttpClientHandler { UseProxy = false } ) ) ;
53+
4254 configureSocketIO ? . Invoke ( services ) ;
4355 } ) ;
4456 // Outgoing args are normalized to camelCase via SerializeArg in Emit.
4557 }
4658
59+ private sealed class NoProxy : IWebProxy
60+ {
61+ public ICredentials Credentials { get ; set ; }
62+
63+ public Uri GetProxy ( Uri destination ) => destination ;
64+
65+ public bool IsBypassed ( Uri host ) => true ;
66+ }
67+
4768 public event EventHandler BridgeDisconnected ;
4869
4970 public event EventHandler BridgeConnected ;
0 commit comments