이미이 문제에 대해 몇 가지 질문이 있지만 회신을해도 문제가 해결되지 않았습니다.NetTcpBinding을 사용하여 소켓 연결이 중단되었습니다.
나는 실행하는 서버에 NetTcpBinding을 가지고, 시간에서 (항상 1 중 20 (60)에 대한 호출과 같은, 완전히 랜덤) 시간 나는 클라이언트 측에서이 예외가 나타날 수
소켓 연결이 중단되었습니다. 이 메시지는 메시지가 처리 중이거나 원격 호스트가 수신 시간 초과를 초과했거나 기본 네트워크 리소스 문제로 인해 발생할 수 있습니다. 로컬 소켓 시간 초과가 '00 : 01 : 00 '이었습니다.
나는이 예외가 클라이언트의 연결이 느릴 때 훨씬 더 자주 발생하는 것으로 나타났습니다.
또한 제한 시간은 1 분이지만 예외는 이미 1 초 정도 후에 발생합니다.
내가 무엇 :
var client = GetClient();
client.Open();
bool success = client.Call(); // Exception occurs here (the return value is a bool)
나는 때때로 서버 측이 예외를 얻을 :
TCP 에러는 (995: 때문에 I/O 작업이 하나 취소되었습니다 스레드 종료 또는 응용 프로그램 요청)가 발생했습니다.
서버 추적을 사용할 수 있지만 동일한 예외가 발생하며 추가적인 통찰력을 제공하지 않습니다.
내 GetClient : 서비스에서
NetTcpBinding netTcpBinding = new NetTcpBinding
{
CloseTimeout = new TimeSpan(0, 0, 30),
OpenTimeout = new TimeSpan(0, 0, 30),
TransferMode = TransferMode.Buffered,
ListenBacklog = 2,
MaxConnections = 2,
MaxReceivedMessageSize = 10485600,
ReaderQuotas = { MaxStringContentLength = 1048576 },
ReliableSession = { Enabled = false },
Security =
{
Mode = SecurityMode.Transport,
Transport = { ClientCredentialType = TcpClientCredentialType.None, ProtectionLevel = ProtectionLevel.EncryptAndSign },
Message = { ClientCredentialType = MessageCredentialType.Windows }
}
};
중요 구성은 :
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" httpHelpPageEnabled="true" httpsHelpPageEnabled="true" />
<serviceAuthorization principalPermissionMode="Custom" serviceAuthorizationManagerType="My.Service.WCF.Tools.CustomAuthorizationManager, My.Service.WCF">
<authorizationPolicies>
<clear/>
<add policyType="My.Service.WCF.Tools.CustomAuthorizationPolicy, My.Service.WCF" />
</authorizationPolicies>
</serviceAuthorization>
<serviceCredentials>
<serviceCertificate findValue="MyService" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
</serviceCredentials>
<serviceThrottling maxConcurrentCalls="65536" maxConcurrentSessions="65536" maxConcurrentInstances="65536" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="ServiceBinding" receiveTimeout="00:05:00" maxConnections="65536" listenBacklog="65536">
<transactionFlow />
<sslStreamSecurity requireClientCertificate="false" />
<binaryMessageEncoding />
<tcpTransport transferMode="Buffered" portSharingEnabled="true" maxReceivedMessageSize="1048576" maxPendingConnections="65536" maxPendingAccepts="10">
<connectionPoolSettings leaseTimeout="00:05:00" idleTimeout="00:05:00" maxOutboundConnectionsPerEndpoint="65536" />
</tcpTransport>
</binding>
<binding name="MexBinding" receiveTimeout="00:05:00" maxConnections="65536" listenBacklog="65536">
<tcpTransport transferMode="Buffered" portSharingEnabled="true" maxReceivedMessageSize="1048576" maxPendingConnections="65536" maxPendingAccepts="10">
<connectionPoolSettings leaseTimeout="00:05:00" idleTimeout="00:05:00" maxOutboundConnectionsPerEndpoint="65536" />
</tcpTransport>
</binding>
</customBinding>
</bindings>
이미 서비스 참조를 업데이트하고, 버퍼 크기의 일부를 변경하려고하지만 (작동하지 않은 단지 bool이 반환 될 때 문제가있을 것이라고 기대하지는 않습니다.)
사용하여 고정 :
OperationContext.Current.OperationCompleted += Test;
private void Test(object sender, EventArgs e)
{
OperationContext.Current.Channel.Close();
}
은 중단하지만 닫기 방법을 사용하지 마십시오!
클라이언트의 netTcpBinding에서도 sendTimeout을 증가 시켰습니까? – Rajesh
그래, 나도 그걸 시도했지만, 1 분이 이미 매우 오랜 시간 이었기 때문에 (한 통화에 보통 10ms 정도 걸린다), 도움이되지 않는다. 또한 예외는 거의 즉시 발생하며 1 분 후에 발생하지는 않습니다. –
또한 고객의 바인딩에서 열기 및 닫기 제한 시간이 30 초입니까? – Rajesh