Модераторы: gambit
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> порт клиента, WCF, callback, права администратора 
V
    Опции темы
Fitc
Дата 17.7.2011, 11:59 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 129
Регистрация: 30.1.2010

Репутация: 1
Всего: 4



Указываю первый незанятый порт обратного вызова пользователя (использую метод продемонстрированный в книге Джувел Лёве). Если запускать приложение на локальном компьютере и с админскими правами, то всё отлично работает, но без админских прав выкидывает ошибку (сейчас не могу предоставить текст ошибки - только в понедельник). Надо как-то регистрировать порт на клиенте?
PM MAIL   Вверх
Fitc
Дата 21.7.2011, 10:12 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 129
Регистрация: 30.1.2010

Репутация: 1
Всего: 4



Та проблема сама собой решилась. 
Теперь другая проблема - при запуске клиента локально все супер, но если через сеть, то выводится нижележащее сообщение:
Цитата

System.TimeoutException: The open operation did not complete within the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout.


Server stack trace: 

   at System.ServiceModel.Channels.ReliableRequestor.ThrowTimeoutException()

   at System.ServiceModel.Channels.ReliableRequestor.Request(TimeSpan timeout)

   at System.ServiceModel.Channels.ClientReliableSession.Open(TimeSpan timeout)

   at System.ServiceModel.Channels.ClientReliableDuplexSessionChannel.OnOpen(TimeSpan timeout)

   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)

   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)

   at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)

   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)

   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)



клиентский конфиг:
Код

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceDebug httpsHelpPageEnabled="false" includeExceptionDetailInFaults="true" />
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <wsDualHttpBinding>
        <binding name="_wsDualHttpBinding" receiveTimeout="03:00:00"
         maxBufferPoolSize="5242888" maxReceivedMessageSize="5242888">
          <reliableSession inactivityTimeout="00:01:00" />
          <security mode="None">
            <message clientCredentialType="None" />
          </security>
        </binding>
      </wsDualHttpBinding>
    <client>
      <endpoint address="http://192.168.0.172/KernelService/KernelService.svc"
        binding="wsDualHttpBinding" bindingConfiguration="_wsDualHttpBinding"
        contract="USS.CommonLibrary.USSWSDL.IKernelServiceContract"
        name="KernelClient" />
      <endpoint address="http://192.168.0.172/KernelService/KernelService.svc"
        binding="wsDualHttpBinding" bindingConfiguration="_wsDualHttpBinding"
        contract="USS.CommonLibrary.USSWSDL.ILearningOperationContract"
        name="LearningClient" />
      <endpoint address="http://192.168.0.172/KernelService/KernelService.svc"
        binding="wsDualHttpBinding" bindingConfiguration="_wsDualHttpBinding"
        contract="USS.CommonLibrary.USSWSDL.IMessageSenderContract"
        name="MessageSenderContractClient" />
    </client>
  </system.serviceModel>
</configuration>


когфиг службы:
Код

<wsDualHttpBinding>
    <binding name="_wsDualHttpBinding" receiveTimeout="03:00:00"
     maxBufferPoolSize="5242888" maxReceivedMessageSize="5242888">
     <reliableSession inactivityTimeout="00:01:00" />
     <security mode="None">
      <message clientCredentialType="None" />
     </security>
    </binding>
   </wsDualHttpBinding>
  </bindings>
        <services>
     <service behaviorConfiguration="Kernel.Service.ServiceBehavior" name="Kernel.Service.KernelService">

       <endpoint binding="wsDualHttpBinding" 
            bindingConfiguration="_wsDualHttpBinding" 
            name="KernelService" 
            contract="USS.CommonLibrary.USSWSDL.IKernelServiceContract" />
       <endpoint binding="wsDualHttpBinding" 
            bindingConfiguration="_wsDualHttpBinding" 
            name="KernelService" 
            contract="USS.CommonLibrary.USSWSDL.ILearningOperationContract" />
       <endpoint binding="wsDualHttpBinding" 
            bindingConfiguration="_wsDualHttpBinding" 
            name="KernelService" 
            contract="USS.CommonLibrary.USSWSDL.IMessageSenderContract" />
        <host>
         <baseAddresses>
          <add baseAddress="http://localhost/KernelService" />
         </baseAddresses>
        </host>
     </service>
    </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="Kernel.Service.ServiceBehavior">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug httpsHelpPageEnabled="false" includeExceptionDetailInFaults="true" />
                </behavior>
            </serviceBehaviors>
        </behaviors>


Это сообщение отредактировал(а) Fitc - 22.7.2011, 11:14
PM MAIL   Вверх
Fitc
Дата 22.7.2011, 11:12 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 129
Регистрация: 30.1.2010

Репутация: 1
Всего: 4



Решил использовать привязку netTcpBinding для обратных вызовов, т.к. не советуют использовать привязку wsdualhttpbinding  для обратных вызовов через интернет (много проблем возникает)
http://stackoverflow.com/

Хост - IIS7. Но опять локально все работает, а запуская через удаленную машину выскакивает сообщение

Цитата

System.ServiceModel.EndpointNotFoundException: Could not connect to net.tcp://192.168.0.172/KernelService/KernelService.svc. The connection attempt lasted for a time span of 00:00:20.9860984. TCP error code 10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 192.168.0.172:808.  ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 192.168.0.172:808

   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)

   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)

   at System.ServiceModel.Channels.SocketConnectionInitiator.Connect(Uri uri, TimeSpan timeout)

   --- End of inner exception stack trace ---



Server stack trace: 

   at System.ServiceModel.Channels.SocketConnectionInitiator.Connect(Uri uri, TimeSpan timeout)

   at System.ServiceModel.Channels.BufferedConnectionInitiator.Connect(Uri uri, TimeSpan timeout)

   at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)

   at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)

   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)

   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)

   at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)

   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)

   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)


клиентский конфиг:
Код

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceDebug httpsHelpPageEnabled="false" includeExceptionDetailInFaults="true" />
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
     <wsHttpBinding>
        <binding name="_wsHttpBinding" receiveTimeout="03:00:00" maxBufferPoolSize="5242888"
          maxReceivedMessageSize="5242888">
          <reliableSession inactivityTimeout="00:01:00" enabled="true" />
          <security mode="None" />
        </binding>
      </wsHttpBinding>
      <netTcpBinding>
        <binding name="_netTcpBinding">
          <security mode="None">
          </security>
        </binding>
      </netTcpBinding>
    <client>
      <endpoint address="http://192.168.0.172/KernelService/KernelService.svc"
        binding="wsHttpBinding" bindingConfiguration="_wsHttpBinding"
        contract="USS.CommonLibrary.USSWSDL.IKernelServiceContract"
        name="KernelClient" />
      <endpoint address="http://192.168.0.172/KernelService/KernelService.svc"
        binding="wsHttpBinding" bindingConfiguration="_wsHttpBinding"
        contract="USS.CommonLibrary.USSWSDL.ILearningOperationContract"
        name="LearningClient" />
      <endpoint address="net.tcp://192.168.0.172/KernelService/KernelService.svc"
        binding="netTcpBinding" bindingConfiguration="_netTcpBinding"
        contract="USS.CommonLibrary.USSWSDL.IMessageSenderContract"
        name="MessageSenderContractClient" />
    </client>
  </system.serviceModel>
</configuration>


когфиг службы:

Код

<wsHttpBinding>
        <binding name="_wsHttpBinding" receiveTimeout="03:00:00" maxBufferPoolSize="5242888"
          maxReceivedMessageSize="5242888">
          <reliableSession inactivityTimeout="00:01:00" enabled="true" />
          <security mode="None" />
        </binding>
      </wsHttpBinding>
      <netTcpBinding>
        <binding name="_netTcpBinding">
          <security mode="None">
          </security>
        </binding>
      </netTcpBinding>
  </bindings>
        <services>
     <service behaviorConfiguration="Kernel.Service.ServiceBehavior" name="Kernel.Service.KernelService">
       <endpoint binding="wsHttpBinding" 
            bindingConfiguration="_wsHttpBinding" 
            name="KernelService" 
            contract="USS.CommonLibrary.USSWSDL.IKernelServiceContract" />
       <endpoint binding="wsHttpBinding" 
            bindingConfiguration="_wsHttpBinding" 
            name="KernelService" 
            contract="USS.CommonLibrary.USSWSDL.ILearningOperationContract" />
       <endpoint binding="netTcpBinding" 
            bindingConfiguration="_netTcpBinding" 
            name="KernelService" 
            contract="USS.CommonLibrary.USSWSDL.IMessageSenderContract" />
        <host>
         <baseAddresses>
          <add baseAddress="http://localhost/KernelService" />
         </baseAddresses>
        </host>
     </service>
    </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="Kernel.Service.ServiceBehavior">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug httpsHelpPageEnabled="false" includeExceptionDetailInFaults="true" />
                </behavior>
            </serviceBehaviors>
        </behaviors>


Это сообщение отредактировал(а) Fitc - 22.7.2011, 11:16
PM MAIL   Вверх
Fitc
Дата 22.7.2011, 16:29 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 129
Регистрация: 30.1.2010

Репутация: 1
Всего: 4



Включив надежность для привязки netTcpBinding - получаю такое сообщение:
Цитата

---------------------------

---------------------------
System.TimeoutException: The open operation did not complete within the allotted timeout of 00:00:00. The time allotted to this operation may have been a portion of a longer timeout. ---> System.TimeoutException: Open timed out after 00:00:00 while establishing a transport session to net.tcp://192.168.0.172/KernelService/KernelService.svc. The time allotted to this operation may have been a portion of a longer timeout. ---> System.TimeoutException: Connecting to via net.tcp://192.168.0.172/KernelService/KernelService.svc timed out after 00:00:00. Connection attempts were made to 0 of 1 available addresses (). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout.

   at System.ServiceModel.Channels.SocketConnectionInitiator.CreateTimeoutException(Uri uri, TimeSpan timeout, IPAddress[] addresses, Int32 invalidAddressCount, SocketException innerException)

   at System.ServiceModel.Channels.SocketConnectionInitiator.Connect(Uri uri, TimeSpan timeout)

   at System.ServiceModel.Channels.BufferedConnectionInitiator.Connect(Uri uri, TimeSpan timeout)

   at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)

   --- End of inner exception stack trace ---

   at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)

   at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)

   --- End of inner exception stack trace ---



Server stack trace: 

   at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)

   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)

   at System.ServiceModel.Channels.ReliableChannelBinder`1.ChannelSynchronizer.SyncWaiter.TryGetChannel()

   at System.ServiceModel.Channels.ReliableChannelBinder`1.ChannelSynchronizer.SyncWaiter.TryWait(TChannel& channel)

   at System.ServiceModel.Channels.ReliableChannelBinder`1.ChannelSynchronizer.TryGetChannel(Boolean canGetChannel, Boolean canCauseFault, TimeSpan timeout, MaskingMode maskingMode, TChannel& channel)

   at System.ServiceModel.Channels.ReliableChannelBinder`1.Send(Message message, TimeSpan timeout, MaskingMode maskingMode)

   at System.ServiceModel.Channels.SendReceiveReliableRequestor.OnRequest(Message request, TimeSpan timeout, Boolean last)

   at System.ServiceModel.Channels.ReliableRequestor.Request(TimeSpan timeout)

   at System.ServiceModel.Channels.ClientReliableSession.Open(TimeSpan timeout)

   at System.ServiceModel.Channels.ClientReliableDuplexSessionChannel.OnOpen(TimeSpan timeout)

   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)

   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)

   at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)

   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)

   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

PM MAIL   Вверх
jonie
Дата 22.7.2011, 20:10 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
****


Профиль
Группа: Завсегдатай
Сообщений: 5613
Регистрация: 21.8.2005
Где: Владимир

Репутация: 15
Всего: 118



включите трассировку да посмотрите более подробно что да как.
Код

<configuration>
...
 <system.diagnostics>
    <sources>
      <source name="System.ServiceModel"
              switchValue="All"
              propagateActivity="true">
        <listeners>
          <add name="traceListener"
              type="System.Diagnostics.XmlWriterTraceListener"
              initializeData= "WCFTraces.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
  
</configuration>


посмотреть можно используя svctraceviewer


--------------------
Что-то не поняли? -> Напейтесь до зеленых человечков... эта сверхцивилизация Вам поможет...
PM MAIL Jabber   Вверх
Fitc
Дата 25.7.2011, 16:44 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 129
Регистрация: 30.1.2010

Репутация: 1
Всего: 4



Цитата(jonie @ 22.7.2011,  20:10)
включите трассировку да посмотрите более подробно что да как.
Код

<configuration>
...
 <system.diagnostics>
    <sources>
      <source name="System.ServiceModel"
              switchValue="All"
              propagateActivity="true">
        <listeners>
          <add name="traceListener"
              type="System.Diagnostics.XmlWriterTraceListener"
              initializeData= "WCFTraces.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
  
</configuration>


посмотреть можно используя svctraceviewer

Спасибо за совет! Но к сожалению ничего нового я там не увидел
PM MAIL   Вверх
Fitc
Дата 27.7.2011, 08:59 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 129
Регистрация: 30.1.2010

Репутация: 1
Всего: 4



вернулся обратно к использованию привязки wsDualHttpBinding, т.к. netTcpBinding требует http прокси на IIS7 для работы в сети/интернете. Может кому нибудь пригодится - решение проблем с привязкойwsDualHttpBinding: проблема была в том, что я не обратил внимание, что в реализации класса атрибута CallbackBaseAddressBehaviorAttribute в книге Джувел Левё адрес обратного вызова был типа http:\\localhost:... который преобразуется в 127.0.0.1, а нужен либо IP клиента либо имя компьютера на месте localhost. Также надо обуздать файерволл на стороне клиента, который обычно блокирует порт, исползуемый в адресе обратного вызова, т.е. надо добавить используемый на клиенте порт в файерволл.
PM MAIL   Вверх
Fitc
Дата 9.8.2011, 21:46 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 129
Регистрация: 30.1.2010

Репутация: 1
Всего: 4



Может кому пригодится: чтобы запустить несколько экземпляров приложения с привязкой wsDualHttpBinding на одном компьютере, я генерирую адрес обратного вызова клиента следующим образом:  
Код

string clientBaseAddress=@"http://" +Environment.MachineName + @":8000/"+GUID.NewGuid();

К сожалению пришлось до этого самому допирать, нигде про это написано не было, везде предлагают искать первый незанятый порт, а тут я просто использую суффикс - новый GUID, порт же остается старым. Победить файервол тоже оказалось нетрудно, можно программно добавить порт клиента в файервол или сделать скрипт непосредственно на сервере, чтоб автоматом порт добавлялся в файервол. Осталось победить проблему, что приложение надо запускать с правами админа... Для этого советуют использовать утилиту netsh, но в моем случае она почему то не помогает... Эх, придется наверно поучиться администрированию...
PM MAIL   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Прежде чем создать тему, посмотрите сюда:
cully
mr.DUDA
Exception

Используйте теги [code=csharp][/code] для подсветки кода. Используйтe чекбокс "транслит" если у Вас нет русских шрифтов.

Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, cully, mr.DUDA, Exception.

 
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | Распределённые приложения и сеть | Следующая тема »


 




[ Время генерации скрипта: 0.0809 ]   [ Использовано запросов: 22 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.