Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Titanium-Web-Proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Titanium-Web-Proxy
Commits
0366b348
Unverified
Commit
0366b348
authored
Nov 21, 2019
by
honfika
Committed by
GitHub
Nov 21, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #673 from ByronAP/master
Add support for connect timeout
parents
e0badec9
2d10f59b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
1 deletion
+38
-1
TcpConnectionFactory.cs
src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+32
-1
ProxyServer.cs
src/Titanium.Web.Proxy/ProxyServer.cs
+6
-0
No files found.
src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
0366b348
...
@@ -348,7 +348,38 @@ retry:
...
@@ -348,7 +348,38 @@ retry:
tcpClient
.
Client
.
SetSocketOption
(
SocketOptionLevel
.
Socket
,
SocketOptionName
.
ReuseAddress
,
true
);
tcpClient
.
Client
.
SetSocketOption
(
SocketOptionLevel
.
Socket
,
SocketOptionName
.
ReuseAddress
,
true
);
}
}
await
tcpClient
.
ConnectAsync
(
ipAddress
,
port
);
var
connectTask
=
tcpClient
.
ConnectAsync
(
ipAddress
,
port
);
await
Task
.
WhenAny
(
connectTask
,
Task
.
Delay
(
proxyServer
.
ConnectTimeOutSeconds
*
1000
));
if
(!
connectTask
.
IsCompleted
||
!
tcpClient
.
Connected
)
{
// here we can just do some cleanup and let the loop continue since
// we will either get a connection or wind up with a null tcpClient
// which will throw
try
{
connectTask
.
Dispose
();
}
catch
{
// ignore
}
try
{
#if NET45
tcpClient
?.
Close
();
#else
tcpClient
?.
Dispose
();
#endif
tcpClient
=
null
;
}
catch
{
// ignore
}
continue
;
}
break
;
break
;
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
...
...
src/Titanium.Web.Proxy/ProxyServer.cs
View file @
0366b348
...
@@ -196,6 +196,12 @@ namespace Titanium.Web.Proxy
...
@@ -196,6 +196,12 @@ namespace Titanium.Web.Proxy
/// </summary>
/// </summary>
public
int
ConnectionTimeOutSeconds
{
get
;
set
;
}
=
60
;
public
int
ConnectionTimeOutSeconds
{
get
;
set
;
}
=
60
;
/// <summary>
/// Seconds server connection are to wait for connection to be established.
/// Default value is 20 seconds.
/// </summary>
public
int
ConnectTimeOutSeconds
{
get
;
set
;
}
=
20
;
/// <summary>
/// <summary>
/// Maximum number of concurrent connections per remote host in cache.
/// Maximum number of concurrent connections per remote host in cache.
/// Only valid when connection pooling is enabled.
/// Only valid when connection pooling is enabled.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment