How to Implement custom proxy logic #1788
-
now i am inherited protected override void ConfigureHandler(ForwarderHttpClientContext context, SocketsHttpHandler handler)
{
base.ConfigureHandler(context, handler);
handler.ConnectCallback = ConnectCallback;
} There are other ways to do this ? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
What specifically are you trying to customize? |
Beta Was this translation helpful? Give feedback.
-
use repo:https://github.com/FastTunnel/FastTunnel/blob/v2/FastTunnel.Core/Forwarder/FastTunnelForwarderHttpClientFactory.cs but socket port can not dispose,mybe during |
Beta Was this translation helpful? Give feedback.
-
@Tratcher Can you understand what that means? what should i do to resolve this problem |
Beta Was this translation helpful? Give feedback.
-
Triage: Looks like the question is "When to close the socket when using |
Beta Was this translation helpful? Give feedback.
-
Keep in mind that the ConnectCallback is not called per request. Streams returned from the ConnectCallback go into SocketHttpHandler's connection pool and are re-used for all requests being sent to the same host. SocketHttpHandler will close the Stream when it's done with the connection. HttpContext.RequestAborted should not be used in this callback since that is a per request event. Even if the client closes the browser/connection, that doesn't mean the ConnectCallback stream should be closed, since it can be re-used by other clients that are sending requests to the same destination. |
Beta Was this translation helpful? Give feedback.
Keep in mind that the ConnectCallback is not called per request. Streams returned from the ConnectCallback go into SocketHttpHandler's connection pool and are re-used for all requests being sent to the same host. SocketHttpHandler will close the Stream when it's done with the connection.
HttpContext.RequestAborted should not be used in this callback since that is a per request event.
Even if the client closes the browser/connection, that doesn't mean the ConnectCallback stream should be closed, since it can be re-used by other clients that are sending requests to the same destination.