Skip to content

Commit 6f99e3d

Browse files
committed
[fix] manage connection manually to prevent request timeout
1 parent 1ddc1b3 commit 6f99e3d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

SLSSDK/Common/Communication/ServiceClientImpl.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,16 +280,18 @@ private static void SetRequestContent(HttpWebRequest webRequest,
280280
webRequest.KeepAlive = false;
281281
webRequest.ServicePoint.ConnectionLeaseTimeout = 5000;
282282
webRequest.ServicePoint.MaxIdleTime = 5000;
283-
//webRequest.ReadWriteTimeout = 100000000;
284283
webRequest.ServicePoint.ConnectionLimit = 1000;
285284
webRequest.ServicePoint.Expect100Continue = false;
286-
//webRequest.ServicePoint.CloseConnectionGroup();
285+
// Generate GUID for connection group name, force close it when request is done.
286+
webRequest.ConnectionGroupName = Guid.NewGuid().ToString();
287+
287288
using (var requestStream = webRequest.GetRequestStream())
288289
{
289290
data.WriteTo(requestStream, webRequest.ContentLength);
290291
data.Seek(0, SeekOrigin.Begin);
291292
requestStream.Flush();
292293
requestStream.Close();
294+
293295
}
294296
data.Close();
295297
data.Dispose();

SLSSDK/Common/Communication/ServiceRequest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ protected virtual void Dispose(bool disposing)
150150
}
151151
if (HttpRequest != null)
152152
{
153+
// force close connection group
154+
//Console.WriteLine(HttpRequest.ConnectionGroupName + "[]" + HttpRequest.ConnectionGroupName.Length.ToString() + "[]" + HttpRequest.ServicePoint.CurrentConnections.ToString());
155+
HttpRequest.ServicePoint.CloseConnectionGroup(HttpRequest.ConnectionGroupName);
153156
HttpRequest.Abort();
154157
HttpRequest = null;
155158
}

0 commit comments

Comments
 (0)