Title: sockets end in close_wait state after some time · Issue #20 · bonesoul/uhttpsharp · GitHub
Open Graph Title: sockets end in close_wait state after some time · Issue #20 · bonesoul/uhttpsharp
X Title: sockets end in close_wait state after some time · Issue #20 · bonesoul/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/bonesoul/uhttpsharp/issues/20
X: @github
Domain: github.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","author":{"url":"https://github.com/GopinathSadasivam","@type":"Person","name":"GopinathSadasivam"},"datePublished":"2019-06-07T04:47:08.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/20/uhttpsharp/issues/20"}
| 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:61e7c74c-bf86-18cf-eebe-6444007a364b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A1E6:3FC61B:7934DE:A4491A:6A5FD537 |
| html-safe-nonce | 18f008fa8f4fbf0126640733c5525b985daa68a12e851350d410cdde3d193e0c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMUU2OjNGQzYxQjo3OTM0REU6QTQ0OTFBOjZBNUZENTM3IiwidmlzaXRvcl9pZCI6IjQ1Mzc4NzE3NTg3ODAyNTc1OTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1a1a9358918ba8fd1bae9fa50ada833b0cab39c9782f023c7ed4db9bc750863a |
| hovercard-subject-tag | issue:453336154 |
| 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/bonesoul/uhttpsharp/20/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ed3a0677fbedf8e21e0e72e71e841567878cd60873a08a6124d055a55b6fa136/bonesoul/uhttpsharp/issues/20 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ed3a0677fbedf8e21e0e72e71e841567878cd60873a08a6124d055a55b6fa136/bonesoul/uhttpsharp/issues/20 |
| 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 | 2a1904016bf220ad1311da188567b50f2c83d69b89a554fd8b017417589fbe29 |
| turbo-cache-control | no-preview |
| go-import | github.com/bonesoul/uhttpsharp git https://github.com/bonesoul/uhttpsharp.git |
| octolytics-dimension-user_id | 73215 |
| octolytics-dimension-user_login | bonesoul |
| octolytics-dimension-repository_id | 2642421 |
| octolytics-dimension-repository_nwo | bonesoul/uhttpsharp |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| 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 | f83c469daaa92993df0b1f479d525995ec8cc172 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width