Search code examples
c#wcfwindows-8microsoft-metro

"A connection attempt failed because the connected party did not properly respond after a period of time" when trying to access the windows service


I have created a windows service and added that service reference to my metro application.

I have created a package and installed the package in another system and also the windows service. The application has installed successfully. Now I try to run the application. the below exception is thrown while calling the service

There was no endpoint listening at "http://localhost/TFSClientWindowsService/TFSCClientWindowsService/ that could accept the message. This is often caused by incorrect address or SOAP action. InnerException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host failed to respond at 127.0.0.1:80

Below is my config settings at service level:

<?xml version="1.0"?>
<configuration>
    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="MyBehavior">
                    <serviceMetadata httpGetEnabled="true"/>
                    <serviceDebug includeExceptionDetailInFaults="true"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <services>
            <service name="TFSClientWindowsService.TFSCClientWindowsService" behaviorConfiguration="MyBehavior">
                <endpoint address="" binding="basicHttpBinding" contract="TFSClientWindowsService.ITFSCClientWindowsService">
                    <identity>
                        <dns value="localhost"/>
                    </identity>
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
                <host>
                    <baseAddresses>
                        <add baseAddress="http://localhost/TFSClientWindowsService/TFSCClientWindowsService/"/>
                    </baseAddresses>
                </host>
            </service>
        </services>
    </system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
</configuration>

when I install the package and access the service it is functioning correctly in my system. but not when I install it in another system.


Solution

  • If you are developing a WinRT app, you cannot talk to a service running on localhost. See this thread for more discussion... http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/17a542e1-8035-4139-9395-d73e3b222eb6