{"action":"created","issue":{"url":"https://api.github.com/repos/guzzle/guzzle/issues/1516","repository_url":"https://api.github.com/repos/guzzle/guzzle","labels_url":"https://api.github.com/repos/guzzle/guzzle/issues/1516/labels{/name}","comments_url":"https://api.github.com/repos/guzzle/guzzle/issues/1516/comments","events_url":"https://api.github.com/repos/guzzle/guzzle/issues/1516/events","html_url":"https://github.com/guzzle/guzzle/issues/1516","id":163520608,"number":1516,"title":"Reading on streamed body doesn't have a timeout","user":{"login":"arnaud-lb","id":365207,"avatar_url":"https://avatars.githubusercontent.com/u/365207?v=3","gravatar_id":"","url":"https://api.github.com/users/arnaud-lb","html_url":"https://github.com/arnaud-lb","followers_url":"https://api.github.com/users/arnaud-lb/followers","following_url":"https://api.github.com/users/arnaud-lb/following{/other_user}","gists_url":"https://api.github.com/users/arnaud-lb/gists{/gist_id}","starred_url":"https://api.github.com/users/arnaud-lb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arnaud-lb/subscriptions","organizations_url":"https://api.github.com/users/arnaud-lb/orgs","repos_url":"https://api.github.com/users/arnaud-lb/repos","events_url":"https://api.github.com/users/arnaud-lb/events{/privacy}","received_events_url":"https://api.github.com/users/arnaud-lb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-02T14:24:15Z","updated_at":"2016-07-02T18:44:06Z","closed_at":null,"body":"When reading from a streamed body, it is not possible to timeout. As a result, the client can get stuck trying to read the body. It can happen in many occasions, for instance if the remote end crashes or just forgets about you, the client will try to read from the socket forever (c.f. half-open tcp).\r\n\r\nExample:\r\n\r\n```\r\n$client = new Client([\r\n    'timeout' => 300,\r\n    'stream' => true,\r\n]);\r\n\r\n$response = $client->get('http://example.com/');\r\n\r\n$body = $response->getBody()->detach();\r\n\r\nwhile (!feof($body)) {\r\n    // this can hang forever\r\n    $line = fgets($body);\r\n}\r\n```\r\n\r\nI would be great if Guzzle allowed to specify a read timeout. I didn't find a way to apply a timeout myself."},"comment":{"url":"https://api.github.com/repos/guzzle/guzzle/issues/comments/230116250","html_url":"https://github.com/guzzle/guzzle/issues/1516#issuecomment-230116250","issue_url":"https://api.github.com/repos/guzzle/guzzle/issues/1516","id":230116250,"user":{"login":"arnaud-lb","id":365207,"avatar_url":"https://avatars.githubusercontent.com/u/365207?v=3","gravatar_id":"","url":"https://api.github.com/users/arnaud-lb","html_url":"https://github.com/arnaud-lb","followers_url":"https://api.github.com/users/arnaud-lb/followers","following_url":"https://api.github.com/users/arnaud-lb/following{/other_user}","gists_url":"https://api.github.com/users/arnaud-lb/gists{/gist_id}","starred_url":"https://api.github.com/users/arnaud-lb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arnaud-lb/subscriptions","organizations_url":"https://api.github.com/users/arnaud-lb/orgs","repos_url":"https://api.github.com/users/arnaud-lb/repos","events_url":"https://api.github.com/users/arnaud-lb/events{/privacy}","received_events_url":"https://api.github.com/users/arnaud-lb/received_events","type":"User","site_admin":false},"created_at":"2016-07-02T18:44:06Z","updated_at":"2016-07-02T18:44:06Z","body":"Hi @mtdowling,\r\n\r\nThe problem is that it happens that fgets never returns :) For instance, when you encounter a [TCP half-open](https://en.wikipedia.org/wiki/TCP_half-open) case. When this happens, a fgets() on a Guzzle's body stream never returns."}}
{"actor":{"display_login":"arnaud-lb"}}