Skip to content

Commit

Permalink
fix gateway timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
CypherPotato committed Nov 12, 2024
1 parent edf73bc commit 4eed66e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 32 deletions.
7 changes: 2 additions & 5 deletions extensions/Sisk.SslProxy/HttpConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public void HandleConnection()
{
gatewayClient.Connect(this.Parent.GatewayEndpoint);
gatewayClient.NoDelay = true;
gatewayClient.SendTimeout = (int)(this.Parent.GatewayTimeout.TotalSeconds);
gatewayClient.ReceiveTimeout = (int)(this.Parent.GatewayTimeout.TotalSeconds);
gatewayClient.SendTimeout = (int)(this.Parent.GatewayTimeout.TotalMilliseconds);
gatewayClient.ReceiveTimeout = (int)(this.Parent.GatewayTimeout.TotalMilliseconds);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -107,9 +107,6 @@ public void HandleConnection()

using (var gatewayStream = gatewayClient.GetStream())
{
gatewayStream.ReadTimeout = (int)(this.Parent.GatewayTimeout.TotalSeconds);
gatewayStream.WriteTimeout = (int)(this.Parent.GatewayTimeout.TotalSeconds);

try
{
sslStream.AuthenticateAsServer(
Expand Down
27 changes: 0 additions & 27 deletions extensions/Sisk.SslProxy/SslProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// File name: SslProxy.cs
// Repository: https://github.com/sisk-http/core

using Sisk.Ssl.HttpSerializer;
using System.Net;
using System.Net.Sockets;
using System.Security.Authentication;
Expand All @@ -29,12 +28,6 @@ public sealed class SslProxy : IDisposable
private readonly Thread channelConsumerThread;
private bool disposedValue;

/// <summary>
/// Gets or sets an boolean indicating if the <see cref="SslProxy"/> should trace the
/// gateway client when starting the proxy.
/// </summary>
public bool CheckGatewayConnectionOnInit { get; set; } = true;

/// <summary>
/// Gets or sets the maximum of open TCP connections this <see cref="SslProxy"/> can mantain
/// open at the same time.
Expand Down Expand Up @@ -109,26 +102,6 @@ public SslProxy(int sslListeningPort, X509Certificate certificate, IPEndPoint re
/// </summary>
public void Start()
{
if (this.CheckGatewayConnectionOnInit)
{
using (var gatewayClient = new TcpClient())
{
gatewayClient.Connect(this.remoteEndpoint);

using (var gatewayStream = gatewayClient.GetStream())
{
bool sentRequest = HttpRequestWriter.TryWriteHttpV1Request(0, gatewayStream, "TRACE", "/", [
("Host", this.GatewayHostname ?? "localhost")
]);

if (!sentRequest)
{
throw new Exception("Couldn't connect to the gateway address.");
}
}
}
}

if (this.KeepAliveEnabled)
{
this.listener.Server.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.TcpKeepAliveInterval, 1);
Expand Down

0 comments on commit 4eed66e

Please sign in to comment.