Title: sockets end in close_wait state after some time · Issue #29 · Code-Sharp/uHttpSharp · GitHub
Open Graph Title: sockets end in close_wait state after some time · Issue #29 · Code-Sharp/uHttpSharp
X Title: sockets end in close_wait state after some time · Issue #29 · Code-Sharp/uHttpSharp
Description: Looks like we are missing a time-out on stream reader in uhttpsharp\HttpClient.cs When remote http client gets disconnected due to some network issues (or because of proxies in between not handling the keep-alive header properly), uHttpS...
Open Graph Description: Looks like we are missing a time-out on stream reader in uhttpsharp\HttpClient.cs When remote http client gets disconnected due to some network issues (or because of proxies in between not handling...
X Description: Looks like we are missing a time-out on stream reader in uhttpsharp\HttpClient.cs When remote http client gets disconnected due to some network issues (or because of proxies in between not handling...
Opengraph URL: https://github.com/Code-Sharp/uHttpSharp/issues/29
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"sockets end in close_wait state after some time","articleBody":"Looks like we are missing a time-out on stream reader in uhttpsharp\\HttpClient.cs\r\n\r\nWhen remote http client gets disconnected due to some network issues (or because of proxies in between not handling the keep-alive header properly), uHttpSharp library code fails to close the socket, this results in open sockets stuck in close_wait state.\r\nAm new to C# not sure how to add this time out.\r\n\r\n {\r\n try\r\n {\r\n await InitializeStream();\r\n\r\n while (_client.Connected)\r\n {\r\n // TODO : Configuration.\r\n var limitedStream = new NotFlushingStream(new LimitedStream(_stream));\r\n\r\n var request = await _requestProvider.Provide(new MyStreamReader(limitedStream)).ConfigureAwait(false);\r\n\r\n if (request != null)\r\n {\r\n UpdateLastOperationTime();\r\n\r\n var context = new HttpContext(request, _client.RemoteEndPoint);\r\n\r\n Logger.InfoFormat(\"{1} : Got request {0}\", request.Uri, _client.RemoteEndPoint);\r\n\r\n\r\n await _requestHandler(context).ConfigureAwait(false);\r\n\r\n if (context.Response != null)\r\n {\r\n var streamWriter = new StreamWriter(limitedStream) { AutoFlush = false };\r\n streamWriter.NewLine = \"\\r\\n\";\r\n await WriteResponse(context, streamWriter).ConfigureAwait(false);\r\n\r\n //v----- connections seem to be stuck here, resulting in piling up of sockets in close_wait state\r\n await limitedStream.ExplicitFlushAsync().ConfigureAwait(false); \r\n\r\n if (!request.Headers.KeepAliveConnection() || context.Response.CloseConnection)\r\n {\r\n _client.Close();\r\n }\r\n }\r\n\r\n UpdateLastOperationTime();\r\n }\r\n else\r\n {\r\n _client.Close();\r\n }\r\n }\r\n }\r\n catch (Exception e)\r\n {\r\n // Hate people who make bad calls.\r\n Logger.WarnException(string.Format(\"Error while serving : {0}\", _remoteEndPoint), e);\r\n _client.Close();\r\n }\r\n\r\n Logger.InfoFormat(\"Lost Client {0}\", _remoteEndPoint);\r\n }\r\n\r\n","author":{"url":"https://github.com/GopinathSadasivam","@type":"Person","name":"GopinathSadasivam"},"datePublished":"2019-06-07T07:11:56.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/29/uHttpSharp/issues/29"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bf53f901-c36e-b956-03b9-607cf8244243 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C78A:18A62A:93E6D36:BF6EE4E:697608AD |
| html-safe-nonce | 998320814e9b422e528ba6c90e10c53bd2d93e38402a215e01b2a64ff0dc98a4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzhBOjE4QTYyQTo5M0U2RDM2OkJGNkVFNEU6Njk3NjA4QUQiLCJ2aXNpdG9yX2lkIjoiNTgwMDU5NTc0NjMzNzgwOTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7c1723facbf044b5dabc98e3e2401fcd0bf9fa66598795a33e82d48a50b5b6d3 |
| hovercard-subject-tag | issue:453370448 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/Code-Sharp/uHttpSharp/29/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9e578a92cd1ac0e12a67b81c2386930c6cca5b5a2dfaf5cab7f1146654cc171e/Code-Sharp/uHttpSharp/issues/29 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9e578a92cd1ac0e12a67b81c2386930c6cca5b5a2dfaf5cab7f1146654cc171e/Code-Sharp/uHttpSharp/issues/29 |
| og:image:alt | Looks like we are missing a time-out on stream reader in uhttpsharp\HttpClient.cs When remote http client gets disconnected due to some network issues (or because of proxies in between not handling... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | GopinathSadasivam |
| hostname | github.com |
| expected-hostname | github.com |
| None | c6814b4cc7afd45cd6e64525d0cff0e76dd802f315a5b0e55a7abda1d1d070d0 |
| turbo-cache-control | no-preview |
| go-import | github.com/Code-Sharp/uHttpSharp git https://github.com/Code-Sharp/uHttpSharp.git |
| octolytics-dimension-user_id | 7625607 |
| octolytics-dimension-user_login | Code-Sharp |
| octolytics-dimension-repository_id | 15547297 |
| octolytics-dimension-repository_nwo | Code-Sharp/uHttpSharp |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | true |
| octolytics-dimension-repository_parent_id | 2642421 |
| octolytics-dimension-repository_parent_nwo | bonesoul/uhttpsharp |
| octolytics-dimension-repository_network_root_id | 2642421 |
| octolytics-dimension-repository_network_root_nwo | bonesoul/uhttpsharp |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4ea235bfed58ef16c8a5642b3ac64b74f10c9f52 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width