Can`t support Server-Sent Event?
Closed this issue · 2 comments
lknbv5 commented
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 commented
This issue is stale because it has been open for 30 days with no activity.
github-actions commented
This issue was closed because it has been inactive for 14 days since being marked as stale.