@@ -4,6 +4,7 @@ namespace ElectronNET.API;
44
55using System ;
66using System . Collections . Generic ;
7+ using System . Net ;
78using System . Threading . Tasks ;
89using ElectronNET . API . Serialization ;
910using SocketIO . Serializer . SystemTextJson ;
@@ -18,13 +19,21 @@ internal class SocketIOConnection : ISocketConnection
1819
1920 public SocketIOConnection ( string uri , string authorization )
2021 {
21- var opts = string . IsNullOrEmpty ( authorization ) ? new SocketIOOptions ( ) : new SocketIOOptions
22+ var opts = new SocketIOOptions
2223 {
23- ExtraHeaders = new Dictionary < string , string >
24+ // The bridge is a loopback IPC channel, so it must never go through a
25+ // (system) proxy - otherwise the handshake never reaches the socket server.
26+ Proxy = DirectProxy . Instance ,
27+ } ;
28+
29+ if ( ! string . IsNullOrEmpty ( authorization ) )
30+ {
31+ opts . ExtraHeaders = new Dictionary < string , string >
2432 {
2533 [ "authorization" ] = authorization
26- } ,
27- } ;
34+ } ;
35+ }
36+
2837 _socket = new SocketIO ( uri , opts ) ;
2938 _socket . Serializer = new SystemTextJsonSerializer ( ElectronJson . Options ) ;
3039 // Use default System.Text.Json serializer from SocketIOClient.
@@ -152,4 +161,15 @@ private void CheckDisposed()
152161 throw new ObjectDisposedException ( nameof ( SocketIOConnection ) ) ;
153162 }
154163 }
164+
165+ private sealed class DirectProxy : IWebProxy
166+ {
167+ public static readonly DirectProxy Instance = new DirectProxy ( ) ;
168+
169+ public ICredentials Credentials { get ; set ; }
170+
171+ public Uri GetProxy ( Uri destination ) => destination ;
172+
173+ public bool IsBypassed ( Uri host ) => true ;
174+ }
155175}
0 commit comments