none
WCF Client freezes with custom bindings in IIS RRS feed

  • Question

  • My WCF service uses the NetHttpBinding but I want make it compatible for client that use .NET 4.0 so I'm trying to use a custom binding. All works fine in local machine with Visual Studio (IIS Express), but not when the service is on an external machine under IIS, the client freezes.

    What am I doing wrong? (I suppose some issue in the callback with duplex contract)

    Service Web.config

    <configuration>
      <system.web>
        <compilation debug="true" targetFramework="4.0" />
      </system.web>
      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior name="ServiceBehavior">
              <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    
        <bindings>
          <customBinding>
            <binding name="ServiceCustom" receiveTimeout="00:20:00" sendTimeout="00:20:00" openTimeout="00:20:00">
              <reliableSession />
              <compositeDuplex />
              <oneWay />
              <!--<mtomMessageEncoding maxBufferSize="2097152"  >
                <readerQuotas maxStringContentLength="2097152"/>
              </mtomMessageEncoding>-->
              <binaryMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647" maxSessionSize="2147483647">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
              </binaryMessageEncoding>
              <httpTransport
                  maxReceivedMessageSize="2147483647"
                  maxBufferPoolSize="2147483647"
                  maxBufferSize="2147483647"
                  keepAliveEnabled="true"
                  allowCookies="false"
                  useDefaultWebProxy="false"/>
              <!--unsafeConnectionNtlmAuthentication="true"-->
    
            </binding>
          </customBinding>
        </bindings>
    
        <services>
          <service behaviorConfiguration="ServiceBehavior" name="WcfServiceNET4.Service1">     
            <endpoint address="" binding="customBinding" bindingConfiguration="ServiceCustom" contract="WcfServiceNET4.IService1"/>
          </service>
        </services>    
      </system.serviceModel>
     <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>   
        <directoryBrowse enabled="false"/>
      </system.webServer>
    
    </configuration>

    Client app.config

    <configuration>
        <system.serviceModel>
            <bindings>
                <customBinding>
                    <binding name="CustomBinding_IService1">
                        <reliableSession />
                        <compositeDuplex />
                        <oneWay />
                        <binaryMessageEncoding />
                        <httpTransport />
                    </binding>
                </customBinding>
            </bindings>
            <client>
                <!--Connecting to the local machine with IIS Express it works fine-->          
                <!--<endpoint address="http://localhost:51528/Service1.svc" binding="customBinding"
                    bindingConfiguration="CustomBinding_IService1" contract="ServiceReference1.IService1"
                    name="CustomBinding_IService1" />-->
    
    
               <!--Connecting to a remote machine with IIS it freezes-->          
               <endpoint address="http://dev6/TestNET4/Service1.svc" binding="customBinding"
                    bindingConfiguration="CustomBinding_IService1" contract="ServiceReference1.IService1"
                    name="CustomBinding_IService1" />          
            </client>
        </system.serviceModel>
    </configuration>

    Service contract

    [ServiceContract(CallbackContract = typeof(IServiceCallback))]
    public interface IService1
    {
         [OperationContract]
         string GetData(int value);    
    }

    Service ICallback

    [ServiceContract]
    public interface IServiceCallback
    {
        [OperationContract]
        void OnProgressChanged(string msg, int percent);
    }

    Client Callback

    [CallbackBehavior(UseSynchronizationContext = false)]
    class ServiceCallback : IService1Callback
    {
       public void OnProgressChanged(string msg, int percent)
       {
          MessageBox.Show(msg);
       }
    }
    Client connection code
    private Service1Client _client;
    private ServiceCallback _callback;
    
    private void btnConnect_Click(object sender, EventArgs e)
    {
         _callback = new ServiceCallback();
         var instanceContext = new InstanceContext(_callback);
         _client = new Service1Client(instanceContext);
    
         _client.Open(); // here the client freezes
    
    }
    (The complete source code here: https://onedrive.live.com/redir?resid=DBC75114109D3C7E!776&authkey=!AAk_zcFd1MoRRSo&ithint=file%2Czip).
    • Edited by ilCosmico Wednesday, April 27, 2016 9:12 AM
    Wednesday, April 27, 2016 9:09 AM

Answers

  • Thanks for the note, but this doesn't help me so much.

    What is going to do for you is help you not drink the MS Kool Aid too much with something like IIS Express and get yourself burnt. IIS Express is no better  than VS's Web server that always got the Web developer brunt when Web application was deployed to the real IIS.
    Thursday, April 28, 2016 1:22 PM
  • Hi ilCosmico,

    As @DA924x said, in our WCF development if we have installed the IIS, it will be better to develop WCF service application in the IIS instead of the IIS express.

    Then for your question I have downloaded your code and hosted your WCF service in my IIS, it just works fine. So I can not reproduce your issue in my side.

    As you said that the client freezes in your side, then can you see the connection between the client and service side by using the Fiddler? Please try to use the fiddler to analyze the request and response. Besides, you can also try to browse the service address in your browser to see if the service is working.

    As you said you have hosted your WCF service in your external machine under IIS, could you please try to host your WCF service in your local IIS to see if it works? If it works, please compare your local IIS or External IIS to see what is the difference. If it does not work, it seems that you do not host the WCF in the IIS correctly, please try to refer to the following article how to host WCF in IIS .

    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, May 5, 2016 8:32 AM
    Moderator

All replies

  • My WCF service uses the NetHttpBinding but I want make it compatible for client that use .NET 4.0 so I'm trying to use a custom binding. All works fine in local machine with Visual Studio (IIS Express), but not when the service is on an external machine under IIS, the client freezes.

    Well, you should have developed and tested against local IIS on your development machine. In no way is IIS Express the real IIS, as you can clearly see now.

    Wednesday, April 27, 2016 2:01 PM
  • Thanks for the note, but this doesn't help me so much.
    Wednesday, April 27, 2016 2:45 PM
  • Thanks for the note, but this doesn't help me so much.

    What is going to do for you is help you not drink the MS Kool Aid too much with something like IIS Express and get yourself burnt. IIS Express is no better  than VS's Web server that always got the Web developer brunt when Web application was deployed to the real IIS.
    Thursday, April 28, 2016 1:22 PM
  • Hi ilCosmico,

    As @DA924x said, in our WCF development if we have installed the IIS, it will be better to develop WCF service application in the IIS instead of the IIS express.

    Then for your question I have downloaded your code and hosted your WCF service in my IIS, it just works fine. So I can not reproduce your issue in my side.

    As you said that the client freezes in your side, then can you see the connection between the client and service side by using the Fiddler? Please try to use the fiddler to analyze the request and response. Besides, you can also try to browse the service address in your browser to see if the service is working.

    As you said you have hosted your WCF service in your external machine under IIS, could you please try to host your WCF service in your local IIS to see if it works? If it works, please compare your local IIS or External IIS to see what is the difference. If it does not work, it seems that you do not host the WCF in the IIS correctly, please try to refer to the following article how to host WCF in IIS .

    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, May 5, 2016 8:32 AM
    Moderator
  • Hi Amy Peng,

    I tried with local IIS and it works fine.

    If I try with IIS installed in another machine it doesn't work.

    I used Fiddler and it gives me fiddler-error-502-proxy-error but I didn't find additional info that could help me. I tried to turn off the Firewall but nothing to do.

    Coming back to my original post, I'd like to make a Custom Binding similar to NetHttpBinding and if I need to open additional port or make some other changes in my firewall, then it is not a solution for me.

    Is there some way to accomplish my goal?

    Friday, May 20, 2016 11:55 AM
  • I used Fiddler and it gives me fiddler-error-502-proxy-error but I didn't find additional info that could help me.

    What it means is that the code blew up running on the Web server. What the real exception is that caused the Web server to through the 502 who knows, because you need to be logging the true exception that happened in the code?

    Monday, May 23, 2016 7:25 PM