WCF over TCP: проблема при вызове с удаленной машины
От: SteeLHeaD  
Дата: 31.05.11 21:19
Оценка: -1
Приветствую!
Написал WCF — based клиент — сервер, работающие через TCP — соединение.
Сервер работает как виндовый сервис, клиент подключается к нему и передает сообщения — в общем,
это просто некоторая модификация чата. сервер — синглтон.
обнаружилась засада, с которой я борюсь уже пару дней: если клиент запущен на машине, которая не находится в моем домене (windows — домене), то она не соединяется с сервером с такой вот безинформативной ошибкой "Подключение к сокету было прервано. Возможно, это вызвано ошибкой обработки сообщения, превышением времени ожидания на удаленном узле или проблемой с выделенным сетевым ресурсом. Тайм-аут локального сокета: "00:00:59.7661950"."
Таймаут соединения не имеет к реальной ошибке никакого отношения, ошибка возникает мгновенно после запуска клиента.
соединение telnet-ом к нужному порту устанавливается без проблем.
То, что ошибка возникает при коннекте машин, находящихся в разных доменах, наводит на мысль о шифровании и SSPI, но я сделал на клиенте и сервере все для отсутствия какой либо security, вот конфиги клиента и сервера:
клиент:


  <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="TcpBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
          <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
          <security mode="None">
            <message clientCredentialType="None"/>
            <transport clientCredentialType="None" protectionLevel="None"/>
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
    <client>
      <endpoint address="net.tcp://192.168.1.2:8000/CallService/service" binding="netTcpBinding" bindingConfiguration="TcpBinding" contract="CallService" name="TcpBinding">
        <identity>
          <userPrincipalName value="davydov@office.local"/>
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>


сервер:

    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="MetadataBehavior">
                    <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8001/CallService/mex"/>
                </behavior>
      </serviceBehaviors>
        </behaviors>
        <services>
            <service behaviorConfiguration="MetadataBehavior" name="CallServer.CallService">
                <endpoint address="service" binding="netTcpBinding" contract="CallServer.ICallService" name="TcpBinding"/>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" name="MexBinding"/>
                <host>
                    <baseAddresses>
                        <add baseAddress="net.tcp://localhost:8000/CallService/"/>
                        <add baseAddress="http://localhost:8001/CallService/"/>
                    </baseAddresses>
                </host>
            </service>
        </services>
    <bindings>
      <netTcpBinding>
        <binding name="TcpBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
          <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
          <security mode="None">
            <message clientCredentialType="None"/>
            <transport clientCredentialType="None" protectionLevel="None"/>
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
    </system.serviceModel>


полный текст ошибки:
message: "Подключение к сокету было прервано. Возможно, это вызвано ошибкой обработки сообщения, превышением времени ожидания на удаленном узле или проблемой с выделенным сетевым ресурсом. Тайм-аут локального сокета: "00:00:59.7661950"."

source: mscorlib

stack trace:

Server stack trace: 
   в System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
   в System.ServiceModel.Channels.SocketConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
   в System.ServiceModel.Channels.DelegatingConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
   в System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper)
   в System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& timeoutHelper)
   в System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
   в System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
   в System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   в System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
   в System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)

Exception rethrown at [0]: 
   в System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   в System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   в System.ServiceModel.ICommunicationObject.Open(TimeSpan timeout)
   в System.ServiceModel.ClientBase`1.System.ServiceModel.ICommunicationObject.Open(TimeSpan timeout)
   в System.ServiceModel.ClientBase`1.Open()
   в CallClient.CCallClient.tryConnectToServer()
15:57:41 GetGlobals.Контрагенты.Get(): точка перед return
15:57:41 GetGlobals.Контрагенты.Get(): return 28089
15:57:42 GetGlobals.События.get: начинаем запрос событий
15:57:42 GetGlobals.События.get: второй варинат (RepList.событиеRepository.GetNew)
15:57:45 СобытиеRepository.GetNew: lat=15:26, return: 4 элементов
15:57:45 GetGlobals.События.get: вытащили 4 событий
15:58:12 CCallClient.tryConnectToServer(): Подключение к сокету было прервано. Возможно, это вызвано ошибкой обработки сообщения, превышением времени ожидания на удаленном узле или проблемой с выделенным сетевым ресурсом. Тайм-аут локального сокета: "00:00:57.0540570".;mscorlib;
Server stack trace: 
   в System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
   в System.ServiceModel.Channels.SocketConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
   в System.ServiceModel.Channels.DelegatingConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
   в System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper)
   в System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& timeoutHelper)
   в System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
   в System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
   в System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   в System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
   в System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)

Exception rethrown at [0]: 
   в System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   в System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   в System.ServiceModel.ICommunicationObject.Open(TimeSpan timeout)
   в System.ServiceModel.ClientBase`1.System.ServiceModel.ICommunicationObject.Open(TimeSpan timeout)
   в System.ServiceModel.ClientBase`1.Open()
   в CallClient.CCallClient.tryConnectToServer()

Могу добавить исходники клиента и сервера, но повторяю, что для машин в одном домене все работает идеально.
А если не в домене — клиент не подключается к серверу, это видно по логам сервера.
у меня уже руки опускаются, потому что не понимаю, в какую сторону копать.
Какие нибудь соображения?
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.