add websocket timeouts
This commit is contained in:
parent
a41c46175b
commit
b8b2c4a7c8
1 changed files with 3 additions and 2 deletions
|
@ -104,12 +104,13 @@ static class Program
|
||||||
|
|
||||||
static async Task<CloseStatus> HandleWebsocket(Websocket ws)
|
static async Task<CloseStatus> HandleWebsocket(Websocket ws)
|
||||||
{
|
{
|
||||||
DataFrame payload = await ws.Read();
|
TimeSpan timeout = TimeSpan.FromMinutes(1);
|
||||||
|
|
||||||
|
DataFrame payload = await ws.Read().WaitAsync(timeout);
|
||||||
if (payload.Opcode != WSOpcode.Close)
|
if (payload.Opcode != WSOpcode.Close)
|
||||||
{
|
{
|
||||||
string result = payload.AsString();
|
string result = payload.AsString();
|
||||||
await ws.Write($"Echoing message: \"{result}\"");
|
await ws.Write($"Echoing message: \"{result}\"").WaitAsync(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CloseStatus.NormalClosure;
|
return CloseStatus.NormalClosure;
|
||||||
|
|
Loading…
Reference in a new issue