none
WCF Routing Service self hosted cross domain RRS feed

  • Question

  • Hi,

    At the company where I'm on a mission, I had to develop a WCF Routing service only accessible to a third party. That 3rd party access the routing url (eg: http://thirdparty.com/routing), the the routing should forward the request appropriately. The problem I have is that whenever the try to access a method of the service they get the following error:

    Can not connect to http://internal.url/OptinsService.svc. TCP error code 10060: A connection attempt failed because the connected party did not properly respond failed after a certain time, or established connection failed because connected host has failed to respond internal.url:170.

    It's like they should know the address where the requested is routed

    Here is the OptinsService.svc service config hosted at http://internal.url:170/OptinsService.svc

      <system.serviceModel>
        <bindings>
          <wsHttpBinding>
            <binding name="WsHttpBinding_IService" receiveTimeout="01:00:00" sendTimeout="01:00:00" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
              <security mode="None">
                <message clientCredentialType="None" />
              </security>
            </binding>
          </wsHttpBinding>
          <mexHttpBinding>
            <binding name="mexHttpBinding_Service" closeTimeout="00:10:00" openTimeout="00:10:00" sendTimeout="00:10:00" />
          </mexHttpBinding>
        </bindings>
        <services>
          <service behaviorConfiguration="ServiceBehaviors" name="Edenred.Data.Optins.Services.OptinsService">
            <endpoint address="" binding="wsHttpBinding" bindingConfiguration="WsHttpBinding_IService" name="wsEndpoint" contract="Edenred.Optins.Services.IOptinsService">
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="mexHttpBinding_Service" name="mexEndpoint" contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:170/OptinsService.svc" />
              </baseAddresses>
              <timeouts closeTimeout="00:10:00" openTimeout="00:05:00" />
            </host>
          </service>
        </services>
    
        <behaviors>
          <serviceBehaviors>
            <behavior name="ServiceBehaviors">
              <serviceMetadata httpGetEnabled="True" />
              <serviceDebug includeExceptionDetailInFaults="True" />
    		  <useRequestHeadersForMetadataAddress>
    			<defaultPorts>
    			<add scheme="http" port="170" />
    			</defaultPorts>
    		  </useRequestHeadersForMetadataAddress>
            </behavior>
          </serviceBehaviors>
        </behaviors>
    
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
      </system.serviceModel>

    And the routing configuration:

      <system.serviceModel>
        <bindings>
          <wsHttpBinding>
            <binding name="wsHttpBinding_Service"   closeTimeout="01:00:00"
              openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00"
    		  maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
    		  useDefaultWebProxy="false">
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    		  <security mode="None">
                <message clientCredentialType="None" />
              </security>
            </binding>
          </wsHttpBinding>
          <mexHttpBinding>
            <binding name="mexHttpBinding_Service" closeTimeout="01:00:00"
              openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00" />
          </mexHttpBinding>
        </bindings>
        <services>
          <service name="System.ServiceModel.Routing.RoutingService" behaviorConfiguration="RoutingServiceBehavior">
            <host>
              <baseAddresses>
    			<add baseAddress="http://thirdparty.com/routing" />
              </baseAddresses>
            </host>
    		<endpoint address="" binding="wsHttpBinding" name="OptinsEndpoint" bindingConfiguration="wsHttpBinding_Service" contract="System.ServiceModel.Routing.IRequestReplyRouter" />
    		<endpoint address="mex" binding="mexHttpBinding" name="mexOptinsEndpoint" bindingConfiguration="mexHttpBinding_Service" contract="System.ServiceModel.Routing.IRequestReplyRouter" />
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="RoutingServiceBehavior">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true" />
              <routing filterTableName="RoutingServiceFilterTable" />
    		  <useRequestHeadersForMetadataAddress>
    			<defaultPorts>
    				<add scheme="http" port="80" />
    			</defaultPorts>
    		  </useRequestHeadersForMetadataAddress>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <client>
          <endpoint address="http://internal.url:170/OptinsService.svc" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_Service" contract="*" name="" />
          <endpoint address="http://internal.url:170/OptinsService.svc/mex" binding="mexHttpBinding" contract="*" name="OptinsMex" />
        </client>
        <routing>
          <filters>
    		<filter name="All" filterType="MatchAll" />
          </filters>
          <filterTables>
            <filterTable name="RoutingServiceFilterTable">
              <add filterName="All" endpointName="OptinsMex" />
            </filterTable>
          </filterTables>
        </routing>
    	<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
      </system.serviceModel>

    Maybe there is something I'm missing.

    One more thing, when, internally, I test the routing service using the IP address it works fine (using WcfTestClient.exe), but not with the DSN name.

    Can anybody help me on this ?

    Thanks in advance.

    Pat


    pat

    Monday, August 1, 2016 12:13 PM

Answers

  • I think what you're saying does not address the situation.

    A routing service needs to have an endpoint address to forward the request to. There lies my problem: what url should I put ?

    The 3rd party can see all the exposed methods but can't execute one because of the error stated.

    Thanks for your help.

    Anyhow, I'll keep digging


    pat

    If you can't figure it out, then you need to take another path,  and you should also stop using the well known low-reserved low-ports.

    https://en.wikipedia.org/wiki/Registered_port

    Friday, August 12, 2016 6:25 PM

All replies

  • Why wouldn't just make a simple WCF service, have it listening on a high port not being used by another application and have the firewall port forward traffic to the port the 3rd party application can use?
    Monday, August 1, 2016 9:05 PM
  • 3rd party uses port 80 (there's nothing else on the routing server), the actual service is on port 170.

    I think that's not the point. What confuses me is that when making a request from the 3rd party the answer is that the actual service address is unknown from 3rd party. That's the whole point of a routing, hide what's beside it right ?


    pat

    Tuesday, August 2, 2016 6:15 AM
  • 3rd party uses port 80 (there's nothing else on the routing server), the actual service is on port 170.

    I think that's not the point. What confuses me is that when making a request from the 3rd party the answer is that the actual service address is unknown from 3rd party. That's the whole point of a routing, hide what's beside it right ?


    pat

    Huh? A firewall can by IP route the traffic to port 170. On top of  that, the service has no business listening on any port below 1023. Ports 0-1023  are the low well known ports that are reserved ports. The URL is converted over to an Internet IP so that traffic can reach the device that is exposed to the Internet, like modem or a router connected or a firewall appliance connected to the modem.

    The Internet WAN client can't see the machine on the LAN. Therefore one uses portforwarding on a firewall or router to route the traffic to the LAN IP of the machine that is hosting the service on the port the service is listening on. 

    You seem to be way off base here.

    Wednesday, August 3, 2016 4:14 AM
  • I think what you're saying does not address the situation.

    A routing service needs to have an endpoint address to forward the request to. There lies my problem: what url should I put ?

    The 3rd party can see all the exposed methods but can't execute one because of the error stated.

    Thanks for your help.

    Anyhow, I'll keep digging


    pat

    Thursday, August 11, 2016 11:37 AM
  • I think what you're saying does not address the situation.

    A routing service needs to have an endpoint address to forward the request to. There lies my problem: what url should I put ?

    The 3rd party can see all the exposed methods but can't execute one because of the error stated.

    Thanks for your help.

    Anyhow, I'll keep digging


    pat

    If you can't figure it out, then you need to take another path,  and you should also stop using the well known low-reserved low-ports.

    https://en.wikipedia.org/wiki/Registered_port

    Friday, August 12, 2016 6:25 PM