[HttpClient] Idle timeout reached with StreamWrapper::createResource #44076
-
Symfony version(s) affected5.3.10 DescriptionI'm trying to implement a simple logging http client decorator to log all http calls with info that I would like to track (Implementation: https://github.com/rmikalkenas/idle-timeout-issue/blob/master/src/HttpClient/LoggingHttpClient.php#L17) It works well while I'm requesting simple data endpoints (for example ones that responds with json content). But when I'm requesting an endpoint with chunked file response and content disposition header, sometimes the request fails with "idle timeout reached" even though response time is fast (less than 1 sec). The interesting fact that it only fails with StreamWrapper being used (https://github.com/rmikalkenas/idle-timeout-issue/blob/master/src/Controller/MainController.php#L31), while using resource and coping content to it works fine (https://github.com/rmikalkenas/idle-timeout-issue/blob/master/src/Controller/MainController.php#L33). Not sure if it's a bug in a Adding a reproducer (look at readme with the info how to launch) How to reproducehttps://github.com/rmikalkenas/idle-timeout-issue Possible SolutionNo response Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The issue is in your code: instead of throwing the exception in the catch block, you should yield the chunk. Note that clients already accept a logger so you might want to leverage that instead of doing this decorator. |
Beta Was this translation helpful? Give feedback.
The issue is in your code: instead of throwing the exception in the catch block, you should yield the chunk.
Note that clients already accept a logger so you might want to leverage that instead of doing this decorator.