mardi 27 mai 2014

c# - le programme d'amorçage personnalisé exécuté à partir de windows-service, impossible de trouver endpoint - Stack Overflow


We have a solution consisting of an windows-service and a console application which acts as a bootstrapper calling a WCF service for work items.


All of this works fine except for when the solution is run in the customers environment which is in a closed network behind a http-proxy for external access. Everything works as expected up to the point where the bootstrapper calls the WCF service, which after 24s exits with the following error:


System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at https://www.MyDomian.com/MyService.svc etc...


Now, here is the kicker. If i start the bootstrapper manually (double-click the exe) it connects to the WCF service without problems.


Known facts



  • Proxy is opened for traffic on port 443 against, www.MyDomian.com

  • We have admin rights on customer computer

  • WCF service is hosted in Windows Azure

  • Solution works on the normal web!

  • WCF is configured to use https

  • https://www.MyDomian.com/MyService.svc is accessible from both IE and Chrome on customer computer

  • IE: Internet Options, is configured with http-proxy

  • Bootstrapper uses channelFactory to connect to wcf service


Code windows-service uses to start the bootstrapper:


var p1 = new Process{StartInfo = { UseShellExecute = false, FileName = MyConsoleApplication.exe } };

p1.StartInfo.UseShellExecute = false;
p1.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
p1.StartInfo.RedirectStandardInput = true;
p1.StartInfo.RedirectStandardError = true;
p1.StartInfo.RedirectStandardOutput = true;

p1.Start();

WCF configuration on host:


<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MyBinding"
maxReceivedMessageSize="500000"
maxBufferSize="500000"
maxBufferPoolSize="500000"
receiveTimeout="00:02:00"
sendTimeout="00:02:00"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>

</bindings>
<services>
<service
name="MyService"
behaviorConfiguration="MyServiceBehavior">
<endpoint address=""
binding="basicHttpBinding"
contract="IMyService"
bindingConfiguration="MyBinding"/>
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpsGetEnabled="true" policyVersion="Policy15" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />


WCF configuration on client:


<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MyBinding"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
receiveTimeout="00:02:00"
sendTimeout="00:02:00"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint name="MyService"
address="https://www.MyDomian.com/MyService.svc"
binding="basicHttpBinding"
contract="IMyService"
bindingConfiguration="MyBinding"/>
</client>


Tried so far:



  • System.Net app config element, such as using proxy defined in Internet Options

  • Multiple configuration variations to bindings. Not tried other bindings

  • process.Verb = "runas"

  • Fiddler2 and WireShark shows that no tunnel is made. (For when it connects shows HTTP tunnel on port 443)

  • Checked for race conditions, but can't find any

  • Correct app config is loaded

  • Smash head against wall


Update 1



  • Running the windows service under a windows user made the bootstrapper connect, but as this will be an installation for several hundred external customers, we won't have that luxury.

  • I ran the service under NETWORK SERVICE and LOCAL SERVICE, but bootstrapper would just quit with exception. Exception indicating lack of priviliges (exceptions were thrown when constructor initialized variables).

  • The http proxy we are behind uses a .pac file. Tried pointing to this with system.net -> defaultProxy, without luck.

  • Trying a different approach now to force the bootstrapper use a specific proxy.


Added this to WCF client config


<system.net>
<defaultProxy useDefaultCredentials="true">
<proxy
proxyaddress="http://proxy.customerDomain.com:8080/"
bypassonlocal="True"
scriptLocation="http://config.customerDomain.com/proxy.pac"/>
</defaultProxy>


What have we missed and/or any suggestions to what can cause this?


Thanks



We have a solution consisting of an windows-service and a console application which acts as a bootstrapper calling a WCF service for work items.


All of this works fine except for when the solution is run in the customers environment which is in a closed network behind a http-proxy for external access. Everything works as expected up to the point where the bootstrapper calls the WCF service, which after 24s exits with the following error:


System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at https://www.MyDomian.com/MyService.svc etc...


Now, here is the kicker. If i start the bootstrapper manually (double-click the exe) it connects to the WCF service without problems.


Known facts



  • Proxy is opened for traffic on port 443 against, www.MyDomian.com

  • We have admin rights on customer computer

  • WCF service is hosted in Windows Azure

  • Solution works on the normal web!

  • WCF is configured to use https

  • https://www.MyDomian.com/MyService.svc is accessible from both IE and Chrome on customer computer

  • IE: Internet Options, is configured with http-proxy

  • Bootstrapper uses channelFactory to connect to wcf service


Code windows-service uses to start the bootstrapper:


var p1 = new Process{StartInfo = { UseShellExecute = false, FileName = MyConsoleApplication.exe } };

p1.StartInfo.UseShellExecute = false;
p1.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
p1.StartInfo.RedirectStandardInput = true;
p1.StartInfo.RedirectStandardError = true;
p1.StartInfo.RedirectStandardOutput = true;

p1.Start();

WCF configuration on host:


<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MyBinding"
maxReceivedMessageSize="500000"
maxBufferSize="500000"
maxBufferPoolSize="500000"
receiveTimeout="00:02:00"
sendTimeout="00:02:00"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>

</bindings>
<services>
<service
name="MyService"
behaviorConfiguration="MyServiceBehavior">
<endpoint address=""
binding="basicHttpBinding"
contract="IMyService"
bindingConfiguration="MyBinding"/>
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpsGetEnabled="true" policyVersion="Policy15" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />


WCF configuration on client:


<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MyBinding"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
receiveTimeout="00:02:00"
sendTimeout="00:02:00"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint name="MyService"
address="https://www.MyDomian.com/MyService.svc"
binding="basicHttpBinding"
contract="IMyService"
bindingConfiguration="MyBinding"/>
</client>


Tried so far:



  • System.Net app config element, such as using proxy defined in Internet Options

  • Multiple configuration variations to bindings. Not tried other bindings

  • process.Verb = "runas"

  • Fiddler2 and WireShark shows that no tunnel is made. (For when it connects shows HTTP tunnel on port 443)

  • Checked for race conditions, but can't find any

  • Correct app config is loaded

  • Smash head against wall


Update 1



  • Running the windows service under a windows user made the bootstrapper connect, but as this will be an installation for several hundred external customers, we won't have that luxury.

  • I ran the service under NETWORK SERVICE and LOCAL SERVICE, but bootstrapper would just quit with exception. Exception indicating lack of priviliges (exceptions were thrown when constructor initialized variables).

  • The http proxy we are behind uses a .pac file. Tried pointing to this with system.net -> defaultProxy, without luck.

  • Trying a different approach now to force the bootstrapper use a specific proxy.


Added this to WCF client config


<system.net>
<defaultProxy useDefaultCredentials="true">
<proxy
proxyaddress="http://proxy.customerDomain.com:8080/"
bypassonlocal="True"
scriptLocation="http://config.customerDomain.com/proxy.pac"/>
</defaultProxy>


What have we missed and/or any suggestions to what can cause this?


Thanks


0 commentaires:

Enregistrer un commentaire