ASP.NET 클라이언트를 찾는 방법 즉시 연결이 끊어졌습니다
-
15-11-2019 - |
문제
나는 Response.IsClientConnected
를 알고 있지만, 나의 시나리오에서는 훌륭한 지연이있다.코드 :
// sample code for sending a dynamic file in chuncks
long bytesSent = 0;
while (continueSending)
{
if (!AskReceiverToContinue())
break;
if (!Response.IsClientConnected)
break;
// Your suggestion goes here... :)
try
{
Response.OutputStream.Write(buffer, 0, buffer.Length);
bytesSent += buffer.Length;
}
Catch
{ // To my experience, this is more reliable than Response.IsClientConnected
continueSending = false;
}
}
.
문제는 Client의 실제 수신 바이트가 내 bytesSent
보다 양의 양이 매우 작습니다.클라이언트가 연결이 끊어지면 훌륭한 지연이있는 상황을 찾아 낸 것처럼 보입니다 (그리고 ASP.NET은 ASP.NET이 상황 (클라이언트가 분리 된) 늦게 알려줍니다.
클라이언트가 연결이 끊어 졌을 때 (실시간) 클라이언트가 분리되었을 때 알아내는 안정적인 방법이 있습니다.
해결책
You are transfering over HTTP, aren't you? If yes, there is no way due to the statelessness of the HTTP protocol. Only thing you have to help you is the timeout, which you are already using.
제휴하지 않습니다 StackOverflow