none
Add Service Reference Error--No connection could be made because the target machine actively refused it 127.0.0.1:8733 RRS feed

  • Question

  • I have a WCF Service hosted by a Windows Service, I tried to create a console project as a client to test the service. Now I right clicked the project/Service References node and added the address http://localhost:8733/KeyValueService/ then click OK.

    Just got an error:

    There was an error downloading 'http://localhost:8733/KeyValueService/_vti_bin/ListData.svc/$metadata'.
    Unable to connect to the remote server
    No connection could be made because the target machine actively refused it 127.0.0.1:8733
    Metadata contains a reference that cannot be resolved: 'http://localhost:8733/KeyValueService/'.
    There was no endpoint listening at http://localhost:8733/KeyValueService/ that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
    Unable to connect to the remote server
    No connection could be made because the target machine actively refused it 127.0.0.1:8733
    If the service is defined in the current solution, try building the solution and adding the service reference again.

    My app.config in the service project:

      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior name="MetadataBehavior">
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <services>
          <service name="VoiceApp.KeyValueService" behaviorConfiguration="MetadataBehavior">
            <endpoint address="http://localhost:8733/KeyValueService/" binding="wsDualHttpBinding" contract="VoiceApp.IService1" />
            <endpoint address="http://localhost:8733/KeyValueService/mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          </service>
        </services>
        <bindings>
          <basicHttpBinding>
          </basicHttpBinding>
        </bindings>
        <client>
        </client>
      </system.serviceModel>
    

    The code in Windows Service:

     protected override void OnStart(string[] args)
            {
                if (serviceHost != null)
                {
                    serviceHost.Close();
                }
                serviceHost = new ServiceHost(typeof(KeyValueService));
                serviceHost.Open();
                IvrApplication.Start();// invoke a thread and many methods in it.
            }
    Two days has passed, I just get nothing. Thanks for help.
    Wednesday, July 2, 2014 8:22 PM

All replies

  • Hi,

    First please try to enter your service address in IE to see if it works.

    In my mind, it seems that your service is not working. After we host the WCF Service in the windows service, then we can see the service in the services list as following(SS1 is my service name):


    Besides, please try to check the following articles to make sure that you have configured it very well.
    #WCF Hosting with Windows Service:
    http://www.codeproject.com/Articles/653493/WCF-Hosting-with-Windows-Service .

    #Example for hosting WCF service in windows service:
    http://dotnetmentors.com/example-for-hosting-wcf-service-in-windows-service.aspx .

    #How to: Host a WCF Service in a Managed Windows Service:
    http://msdn.microsoft.com/en-us/library/ms733069(v=vs.110).aspx .

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, July 3, 2014 6:01 AM
    Moderator
  • Make sure your firewall on the host machine is not blocking the port. If yes then create an rule in firewall to bypass the port of service i.e.8733. P.S. - If you're just testing it on your machine you can simply turnoff your firewall and verify if the firewall is blocking the port.
    Thursday, July 3, 2014 7:03 AM
  • Guys, the windows service does run and windows firewall is turned off. But it s just not working even in the browser....
    Thursday, July 3, 2014 1:11 PM
  • Hi,

    As you said that your service is not working in the browser, so your service does not work.

    Then what error do you meet when you browser the service in the IIS?

    Then I will recommad to check articles in my first reply to create the service and host the service in the windows service step by step.

    #WCF Hosting with Windows Service:
    http://www.codeproject.com/Articles/653493/WCF-Hosting-with-Windows-Service .

    #Example for hosting WCF service in windows service:
    http://dotnetmentors.com/example-for-hosting-wcf-service-in-windows-service.aspx .

    #How to: Host a WCF Service in a Managed Windows Service:
    http://msdn.microsoft.com/en-us/library/ms733069(v=vs.110).aspx .

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, July 4, 2014 7:10 AM
    Moderator
  • Well.. then check if the port 8733 is not being used by another application. Trying changing the port.

    Friday, July 4, 2014 9:56 AM
  • @Peng, let me be specific. The three examples in your first reply are not fitting with my case. The two examples all have two projects, "Class Library" project and "Windows Service" project. The third example seems to create WCF project first, then add a Windows service class to host it then.

    My case is different, I already have had a Windows service project, the project contained a socket server class. For some reason, we wanted to replace the socket server with WCF service. So my idea was to add a WCF service to the existing project(not to create a new class library project). The reason is there is a collection in the Windows service application can't live in WCF service. So I didn't want to create a new WCF project, otherwise the collection could not communicate the application. I am not sure whether the idea is correct, which is add a WCF service to an existing Windows service.

    By the way, the WCF is sort of duplex type. Change port doesn't work as well.

    Friday, July 4, 2014 12:23 PM