Search code examples
wcfwcf-security

WCF gives error 10061 after starting the service with another username


I have a service running for over a year on a dedicated windows server. On my client computer I have a winforms client that communicates with this service using WCF

This works without problems for more than a year now.
But now company policy has changed and I had to start the service with another account than the domain\administrator account.
The account that is used is also a domain account and it does has administrator rights.

But since this my winforms client cannot connect to it anymore, I always get this error :

---------------------------
Could not connect to net.tcp://localhost:8001/CommunicationService. 
The connection attempt lasted for a time span of 00:00:02.0176000. 
TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8001. 
---------------------------

So I guess I need to do give some rights to something but I have no clue here.
Can someone explain what I need to do to get this working again ?

Remember that both the service and the client are NOT changed in any way, and it worked perfect until I had to start the service with another user account.
So it should not be a firewall issue I think nor any bug in my code.

EDIT:
this is the config file of the service:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
   <system.serviceModel>
      <services>
         <service name="CommunicationService" behaviorConfiguration="debug">
            <endpoint address="net.tcp://localhost:8001/CommunicationService" binding="netTcpBinding" contract="ICommunication"/>
         </service>
      </services>
    <bindings>
      <netTcpBinding>
        <binding>
          <security mode="None"></security>
        </binding>
      </netTcpBinding>
    </bindings>
      <behaviors>
        <serviceBehaviors>
          <behavior name="debug">
            <serviceDebug includeExceptionDetailInFaults="true" />
          </behavior>
        </serviceBehaviors>
      </behaviors>
   </system.serviceModel>
</configuration>

and this is the config of my client:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
  <system.serviceModel>
    <client>
      <endpoint address="net.tcp://192.0.137.198:8001/CommunicationService" binding="netTcpBinding" contract="ICommunication"/>
    </client>
    <bindings>
      <netTcpBinding>
        <binding sendTimeout="00:00:05">
      <security mode="None"></security>
    </binding>
      </netTcpBinding>
    </bindings>
  </system.serviceModel>  
</configuration>

EDIT:

If I run the client on the same computer as the service than it works. I tried with this

netsh http add urlacl url=http://127.0.0.1:8001/MyUri user=domain\user 

but no help here. I found this command here HTTP could not register URL http://+:8000/HelloWCF/. Your process does not have access rights to this namespace but I have no clue what parameters I need to use for it


Solution

  • got it working. It seems I had the wrong config file for the client, its endpoint was set to 127.0.0.1 in stead of pointing to the correct service.