title: WCF - (504) The server did not return a response for this request
body: <p>I have a JSONP WCF Endpoint and am trying to track down why I am getting a 504 error.</p>
  
  <blockquote>
    <p>HTTP/1.1 504 Fiddler - Receive Failure<br>
    Content-Type: text/html<br>
    Connection: close<br>
    Timestamp: 11:45:45:9580<br>
    ReadResponse() failed: The server did not return a response for this request.</p>
  </blockquote>
  
  <p>I can set a breakpoint anywhere inside of my Endpoint, step through code, see it successfully gather the data required for the response, hit the final line of code, then as soon as I step out of the WCF call I get a 504 error.  <strong>This was working last week!</strong></p>
  
  <pre><code>[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
  [ServiceContract(Name = "NegotiateService", Namespace = "http://rivworks.com/Services/2009/01/15")]
  public class NegotiateService //: svcContracts.INegotiateService
  {
      public NegotiateService() { }
  
      [OperationContract]
      [WebGet(ResponseFormat = WebMessageFormat.Json)]
      public dataObjects.NegotiateSetup GetSetup(string method, string jsonInput)
      {
          dataObjects.NegotiateSetup resultSet = new dataObjects.NegotiateSetup();
  
          using (RivFeedsEntities1 _dbFeed = new FeedStoreReadOnly(AppSettings.FeedAutosEntities_connString, "", "").ReadOnlyEntities())
          {
              using (RivEntities _dbRiv = new RivWorksStore(AppSettings.RivWorkEntities_connString, "", "").NegotiationEntities())
              {
                  // Deserialize the input and get all the data we need...
                  Newtonsoft.Json.Linq.JObject o = Newtonsoft.Json.Linq.JObject.Parse(jsonInput);
                  string urlRef = String.Format("{0}", o["ref"]).Replace("\"", "");
                  string clientDate = String.Format("{0}", o["dt"]).Replace("\"", "");
                  string ProductID = String.Format("({0})", o["productId"]).Replace("\"", "");
                  string SKU = String.Format("{0}", o["sku"]).Replace("\"", "");
                  string env = String.Format("{0}", o["env"]).Replace("\"", "");
  
                  IList&lt;Product&gt; efProductList = null;
                  Product workingProduct = null;
                  vwCompanyDetails workingCompany = null;
                  bool foundItem = false;
  
                  if (!String.IsNullOrEmpty(SKU))
                      efProductList = _dbRiv.Product.Include("Company").Where(a =&gt; a.SKU == SKU).ToList();
                  else if (!String.IsNullOrEmpty(ProductID))
                      efProductList = _dbRiv.Product.Include("Company").Where(a =&gt; a.ProductId == new Guid(ProductID)).ToList();
  
                  foreach (Product product in efProductList)
                  {
                      if (String.IsNullOrEmpty(product.URLDomain))
                      {
                          var efCompany = _dbRiv.vwCompanyDetails
                                                .Where(a =&gt; a.defaultURLDomain != null &amp;&amp; a.CompanyId == product.Company.CompanyId)
                                                .FirstOrDefault();
  
                          if (efCompany != null &amp;&amp; urlRef.Contains(efCompany.defaultURLDomain))
                          {
                              foundItem = true;
                              workingProduct = product;
                              workingCompany = efCompany;
                          }
                      }
                      else
                      {
                          if (urlRef.Contains(product.URLDomain))
                          {
                              foundItem = true;
                              workingProduct = product;
                              workingCompany = _dbRiv.vwCompanyDetails
                                                     .Where(a =&gt; a.CompanyId == product.Company.CompanyId)
                                                     .FirstOrDefault();
                          }
                      }
                  }
  
                  if (foundItem)
                  {
                      try
                      {
                          // Update the resultSet...
                          if (workingProduct != null &amp;&amp; workingCompany != null)
                          {
                              string rootUrl = String.Empty;
                              try
                              {
                                  rootUrl = AppSettings.RootUrl;
                              }
                              catch
                              {
                                  rootUrl = env + @"/";
                              }
                              resultSet.button = workingProduct.ButtonConfig;
                              resultSet.swfSource = String.Format(@"{0}flash/negotiationPlayer.swf", rootUrl);
                              resultSet.gateway = rootUrl;
                              resultSet.productID = workingProduct.ProductId.ToString();
                              resultSet.buttonPositionCSS = workingProduct.buttonPositionCSS;
                          }
                      }
                      catch (Exception ex)
                      {
                          log.WriteLine("      ERROR: ", ex.Message);
                          log.WriteLine("STACK TRACE: ", ex.StackTrace);
                      }
                  }
              }
          }
          return resultSet;
      }
  }
  </code></pre>
  
  <p>My web.config:</p>
  
  <pre><code>&lt;!-- WCF configuration --&gt;
  &lt;system.serviceModel&gt;
    &lt;behaviors&gt;
      &lt;endpointBehaviors&gt;
        &lt;behavior name="JsonpServiceBehavior"&gt;
          &lt;webHttp /&gt;
        &lt;/behavior&gt;
      &lt;/endpointBehaviors&gt;
    &lt;/behaviors&gt;
  
    &lt;services&gt;
      &lt;service name="RivWorks.Web.Service.NegotiateService"&gt;
        &lt;endpoint address=""
                binding="customBinding"
                bindingConfiguration="jsonpBinding"
                behaviorConfiguration="JsonpServiceBehavior"
                contract="RivWorks.Web.Service.NegotiateService" /&gt;
      &lt;/service&gt;
    &lt;/services&gt;
  
    &lt;extensions&gt;
      &lt;bindingElementExtensions&gt;
        &lt;add name="jsonpMessageEncoding" type="RivWorks.Web.Service.JSONPBindingExtension, RivWorks.Web.Service, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /&gt;
      &lt;/bindingElementExtensions&gt;
    &lt;/extensions&gt;
  
    &lt;bindings&gt;
      &lt;customBinding&gt;
        &lt;binding name="jsonpBinding" &gt;
          &lt;jsonpMessageEncoding /&gt;
          &lt;httpTransport manualAddressing="true"/&gt;
        &lt;/binding&gt;
      &lt;/customBinding&gt;
    &lt;/bindings&gt;    
  &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>As I said, the code runs all the way through so I am trying to figure out why it is not sending a response.</p>