{"action":"created","issue":{"url":"https://api.github.com/repos/mono/mono/issues/8775","repository_url":"https://api.github.com/repos/mono/mono","labels_url":"https://api.github.com/repos/mono/mono/issues/8775/labels{/name}","comments_url":"https://api.github.com/repos/mono/mono/issues/8775/comments","events_url":"https://api.github.com/repos/mono/mono/issues/8775/events","html_url":"https://github.com/mono/mono/issues/8775","id":324607333,"node_id":"MDU6SXNzdWUzMjQ2MDczMzM=","number":8775,"title":"Timeout in HttpWebRequest.GetResponse() when called repeatedly","user":{"login":"AlexRixhardson","id":39428930,"node_id":"MDQ6VXNlcjM5NDI4OTMw","avatar_url":"https://avatars1.githubusercontent.com/u/39428930?v=4","gravatar_id":"","url":"https://api.github.com/users/AlexRixhardson","html_url":"https://github.com/AlexRixhardson","followers_url":"https://api.github.com/users/AlexRixhardson/followers","following_url":"https://api.github.com/users/AlexRixhardson/following{/other_user}","gists_url":"https://api.github.com/users/AlexRixhardson/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexRixhardson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexRixhardson/subscriptions","organizations_url":"https://api.github.com/users/AlexRixhardson/orgs","repos_url":"https://api.github.com/users/AlexRixhardson/repos","events_url":"https://api.github.com/users/AlexRixhardson/events{/privacy}","received_events_url":"https://api.github.com/users/AlexRixhardson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-19T06:54:07Z","updated_at":"2018-06-07T18:40:10Z","closed_at":null,"author_association":"NONE","body":"## Steps to Reproduce\r\n\r\n1. Create a web app which calls HttpWebRequest.GetResponse() repeatedly\r\n2. Run app on Mono 5.12 + Apache + CentOS 7 configuration\r\n\r\n### Current Behavior\r\n\r\nCalls to GetResponse() will eventually stop working and will fail with:\r\n\r\n```\r\nThe operation has timed out., Stack Trace:   at System.Net.HttpWebRequest+<RunWithTimeoutWorker>d__244`1[T].MoveNext () [0x000ba] in <93075ab5c03242e39aa9261622b472b8>:0 \r\n--- End of stack trace from previous location where exception was thrown ---\r\n  at System.Net.HttpWebRequest.GetResponse () [0x00013] in <93075ab5c03242e39aa9261622b472b8>:0 \r\n```\r\n\r\nApp does not recover. Restart of the Mono process is required.\r\n\r\n### Expected Behavior\r\n\r\nGetResponse() method not to fail if called repeatedly\r\n\r\n### Sample Code\r\n\r\nThe following code must be repeatedly called for the bug to start occurring:\r\n\r\n```\r\n            Uri myUri = new Uri(...);\r\n            WebRequest myWebRequest = HttpWebRequest.Create(myUri);\r\n            HttpWebRequest request = (HttpWebRequest)myWebRequest;\r\n\r\n            request.Method = \"GET\";\r\n            request.ContentType = \"application/json; charset=utf-8\";\r\n\r\n            using (Stream s = request.GetResponse().GetResponseStream())\r\n            {\r\n                using (StreamReader sr = new StreamReader(s))\r\n                {\r\n                    var jsonData = sr.ReadToEnd();\r\n                    return;\r\n                }\r\n            }\r\n```\r\n\r\n## On which platforms did you notice this\r\n\r\n[ ] macOS\r\n[X ] Linux\r\n[ ] Windows\r\n\r\n**Version Used**:\r\n\r\n```\r\nMono JIT compiler version 5.12.0.233 (tarball Tue May  8 09:28:02 UTC 2018)\r\nCopyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com\r\n        TLS:           __thread\r\n        SIGSEGV:       altstack\r\n        Notifications: epoll\r\n        Architecture:  amd64\r\n        Disabled:      none\r\n        Misc:          softdebug\r\n        Interpreter:   yes\r\n        LLVM:          supported, not enabled.\r\n        GC:            sgen (concurrent by default)\r\n\r\n```\r\n\r\n## Stacktrace\r\n\r\n```\r\nThe operation has timed out., Stack Trace:   at System.Net.HttpWebRequest+<RunWithTimeoutWorker>d__244`1[T].MoveNext () [0x000ba] in <93075ab5c03242e39aa9261622b472b8>:0 \r\n--- End of stack trace from previous location where exception was thrown ---\r\n  at System.Net.HttpWebRequest.GetResponse () [0x00013] in <93075ab5c03242e39aa9261622b472b8>:0 \r\n```"},"comment":{"url":"https://api.github.com/repos/mono/mono/issues/comments/395523163","html_url":"https://github.com/mono/mono/issues/8775#issuecomment-395523163","issue_url":"https://api.github.com/repos/mono/mono/issues/8775","id":395523163,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NTUyMzE2Mw==","user":{"login":"smr888","id":470147,"node_id":"MDQ6VXNlcjQ3MDE0Nw==","avatar_url":"https://avatars2.githubusercontent.com/u/470147?v=4","gravatar_id":"","url":"https://api.github.com/users/smr888","html_url":"https://github.com/smr888","followers_url":"https://api.github.com/users/smr888/followers","following_url":"https://api.github.com/users/smr888/following{/other_user}","gists_url":"https://api.github.com/users/smr888/gists{/gist_id}","starred_url":"https://api.github.com/users/smr888/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smr888/subscriptions","organizations_url":"https://api.github.com/users/smr888/orgs","repos_url":"https://api.github.com/users/smr888/repos","events_url":"https://api.github.com/users/smr888/events{/privacy}","received_events_url":"https://api.github.com/users/smr888/received_events","type":"User","site_admin":false},"created_at":"2018-06-07T18:40:10Z","updated_at":"2018-06-07T18:40:10Z","author_association":"NONE","body":"I have never done what you are doing quite that way . . . I find myself wondering if the HttpWebResponse you are creating with your call to request.GetResponse() is ever being closed, which it needs to be.  I'm not sure the using(Stream s . . .  would do so. I think it just closes the stream, but not the response.\r\n\r\nAnyway, just to see what happens you could try it like this, which is similar to what we do all the time:\r\n\r\n```C#\r\nusing (HttpWebResponse response = request.GetResponse())\r\n{\r\n    if (response == null)\r\n         return;  // or whatever is appropriate\r\n    using (StreamReader sr = new StreamReader(response.GetResponseStream()))\r\n    {\r\n        var jsonData = sr.ReadToEnd();\r\n        return;\r\n    }\r\n}\r\n\r\nand see if that makes any difference."}}
{"actor":{"display_login":"smr888"}}