0

I'm trying to consume a web service and I can do this from a barebone console application that I start manually on the server. In the web application on the same server that is using HangFire to schedule jobs and call the web service every nth minute I get a "The remote server returned an error: (504) Gateway Timeout".

Unfortunately the service is not public so it's not possible to include a link to it for testing. The method I'm calling in this question is just a simple echo method that returns the same message I'm sending in the request.

The same code is used for making the call with the same binding and endpoint setup. When testing both applications are run on the same server.

Any suggestions to what can cause these different results or how I can find out the real reason for getting this error from the web application?

var binding = new BasicHttpsBinding
{
    MaxBufferSize = int.MaxValue,
    MaxReceivedMessageSize = int.MaxValue,
    ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max
};
var endpoint = new EndpointAddress(new Uri(settings.serviceUrl));

var channelFactory = new ChannelFactory<SoapApplication>(binding, endpoint);

// skip validating self signed cert for test
channelFactory.Credentials.ServiceCertificate.SslCertificateAuthentication = new X509ServiceCertificateAuthentication()
{ CertificateValidationMode = X509CertificateValidationMode.Custom, CustomCertificateValidator = new CustomValidator() };

var serviceClient = channelFactory.CreateChannel();

Console.WriteLine("Sending echo message...");

var echo = new Echo
{
    text = "This is a test"
};

var response = await serviceClient.echoAsync(new Echo1(echo));

1 Answers1

0

I don't know the specific environment of your server side, so I can't reproduce the problem to find the specific cause of the problem.

As mentioned in this answer: you may need to go and check if there is a problem with the request or the host itself, maybe the host is stuck in an infinite loop trying to process your request, or maybe it just "hangs" and the proxy handling your request gives up and sent you a request.

Xudong Peng
  • 1,463
  • 1
  • 4
  • 9