IzyPro / WatchDog

WatchDog is a Realtime Message, Event, HTTP (Request & Response) and Exception logger and viewer for ASP.Net Core Web Apps and APIs. It allows developers log and view messages, events, http requests made to their web application and also exception caught during runtime in their web applications, all in Realtime.
MIT License
765 stars 115 forks source link

Can`t support Server-Sent Event? #150

Closed lknbv5 closed 3 months ago

lknbv5 commented 5 months ago
public async Task TimeSSE(CancellationToken cancellationToken)
{
    Response.Headers.Add("Content-Type", "text/event-stream;charset=utf-8");
    Response.Headers.Add("Cache-Control", "no-cache");
    Response.Headers.Add("Connection", "keep-alive");
    try
    {
        while (!cancellationToken.IsCancellationRequested)
        {
            Debug.WriteLine("输出中");
            await Response.WriteAsync("event:test\n");
            await Response.WriteAsync("data:" + DateTime.Now.ToLongTimeString() + "\n");
            await Response.WriteAsync("retry: 1000\n\n");
            await Response.Body.FlushAsync(); // 刷新缓冲区,立即发送数据到客户端
            await Task.Delay(1000); // 等待1秒后再次发送
        }
    }
    catch (OperationCanceledException)
    {

    }
}

I have an SSE interface, but after using WatchDog, the client can't get the Event in time, I tried to add this route address in the blacklist to eliminate the effect, but it still doesn't work!

Is this a bug, or is there another way to handle this?

github-actions[bot] commented 4 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 3 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.