title: Can't access WCF websocket service from WPF application
body: <p>I'm trying to use a simple WCF service via Websockets (netHttpBinding with <code>transportUsage="Always"</code>). </p>
  
  <p>It works fine when consuming the service from a console application, but throws a timeout error, when consuming it from a WPF application:</p>
  
  <blockquote>
    <p>This request operation sent to
    <a href="http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/" rel="nofollow">http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/</a>
    did not receive a reply within the configured timeout (00:01:00).</p>
  </blockquote>
  
  <p>There is not timeout when switching from <code>transportUsage="Always"</code> to <code>transportUsage="Never"</code>.</p>
  
  <p><strong>How can I access a websocket WCF service from a WPF application?</strong></p>
  
  <p>Service Contract:</p>
  
  <pre><code>[ServiceContract]
  public interface IService1
  {
      [OperationContract]
      string GetData(int value);
  
  }
  </code></pre>
  
  <p>The Service:</p>
  
  <pre><code>public class Service1 : IService1
  {
      public string GetData(int value)
      {
          return string.Format("You entered: {0}", value);
      }
  }
  </code></pre>
  
  <p>The configuration:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
    &lt;services&gt;
      &lt;service name="WcfServiceLibrary1.Service1"&gt;
        &lt;host&gt;
          &lt;baseAddresses&gt;
            &lt;add baseAddress = "http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/" /&gt;
          &lt;/baseAddresses&gt;
        &lt;/host&gt;
        &lt;endpoint address="" binding="netHttpBinding" contract="WcfServiceLibrary1.IService1" bindingConfiguration="My_NetHttpBindingConfig"&gt;
          &lt;identity&gt;
            &lt;dns value="localhost"/&gt;
          &lt;/identity&gt;
        &lt;/endpoint&gt;
        &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/&gt;
      &lt;/service&gt;
    &lt;/services&gt;
    &lt;bindings&gt;
      &lt;netHttpBinding&gt;
        &lt;binding name="My_NetHttpBindingConfig"&gt;
          &lt;webSocketSettings transportUsage="Always"/&gt;
        &lt;/binding&gt;
      &lt;/netHttpBinding&gt;
    &lt;/bindings&gt;
    &lt;behaviors&gt;
      &lt;serviceBehaviors&gt;
        &lt;behavior&gt;
          &lt;serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/&gt;
          &lt;serviceDebug includeExceptionDetailInFaults="False" /&gt;
        &lt;/behavior&gt;
      &lt;/serviceBehaviors&gt;
    &lt;/behaviors&gt;
  &lt;/system.serviceModel&gt; 
  </code></pre>
  
  <p>Console Code (works fine):</p>
  
  <pre><code>    static void Main(string[] args)
      {
  
          Service1Client c = new Service1Client("NetHttpBinding_IService1");
          string s = c.GetData(8);
          Console.WriteLine(s);
          Console.ReadLine();
      }
  </code></pre>
  
  <p>WPF code (doesn't work):</p>
  
  <pre><code>    private void Button_Click(object sender, RoutedEventArgs e)
      {
          Service1Client c = new Service1Client("NetHttpBinding_IService1");
          string s = c.GetData(5);
          MessageTextBlock.Text=s;
      }
  </code></pre>
  
  <p>The configuration is identical for both WPF and the console application:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
      &lt;bindings&gt;
          &lt;netHttpBinding&gt;
              &lt;binding name="NetHttpBinding_IService1"&gt;
                  &lt;webSocketSettings transportUsage="Always" /&gt;
              &lt;/binding&gt;
          &lt;/netHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;client&gt;
          &lt;endpoint address="ws://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/"
              binding="netHttpBinding" bindingConfiguration="NetHttpBinding_IService1"
              contract="ServiceReference1.IService1" name="NetHttpBinding_IService1"&gt;
              &lt;identity&gt;
                  &lt;dns value="localhost" /&gt;
              &lt;/identity&gt;
          &lt;/endpoint&gt;
      &lt;/client&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>