Open saksham-simcorp opened 3 days ago
YARP does not do any such buffering, it is likely the tool you're using to view the response (Browser?) is only rendering it once it has received all of it.
E.g. if you try reading the response with HttpClient, do you see it being delayed?
using var client = new HttpClient();
await using Stream stream = await client.GetStreamAsync("http://localhost:5000/yourApi");
byte[] buffer = new byte[1000];
int read;
while ((read = await stream.ReadAsync(buffer)) >= 0)
{
Console.WriteLine(Encoding.UTF8.GetString(buffer.AsSpan(0, read)));
}
Same issue is there while running from this HttpClient code which I am facing on browser with js client. When I bypass gateway and access service directly it responds properly and I can see response chunks being printed on console. Gateway has Dapr & Yarp configured for forwarding request and no additional middleware. Do you think it could be a issue with Dapr?
Can you please share your YARP configuration / create a minimal runnable repro? YARP doesn't do any buffering so that's odd.
Describe the bug
I am currently having setup of microservices in dotnet where Dapr with YARP is configured on gateway. In one of the service I have a api endpoint which streams response of type
AsyncEnumerable<string>
. But when hitting api through gateway responses are not streamed and if keeps in pending state until completed.To Reproduce
What steps can we follow to reproduce the issue? When I try hitting endpoint of service directly I get expected results and can see chunks being logged in browser console as they are returned, but when request goes through gateway it keeps in pending status until it gets processed completely then only it gives response. Also when I hit service directly I get response headers as Transfer Encoding "chunked", but when routing through gateway this doesn't happens. I also tried setting
AllowResponseBuffering
flag to false through app-setting configuration & also throughappconfig.yaml
in docker compose command to run dapr.Further technical details