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));