When consuming WCF in a local environment, everything is working just fine.
But when consuming WCF hosted on some external location (Azure etc.), for request process that lasts longer than 1 minute, I get the error:
System.TimeoutException: 'The request channel timed out while waiting for a reply after 01:01:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.'
WebException: The remote server returned an error: (504) Gateway Timeout.
This error is showing after 1 minute, not after 1 hour as it says.
The service is using wsHttpBinding.
Any idea what could be a problem here?
Related
In our setup we have a WCF client in a windows service that needs to request configuration from a central server hosting a WCF endpoint. Client/Server communication works like a charm when the client machine is fully up and running but fails during boot.
below is the Exception throw:
EXCEPTION THROWN: System.TimeoutException: Client is unable to finish
the security negotiation within the configured timeout
(00:00:19.9839990). The current negotiation leg is 1
(00:00:19.8689925).---> System.TimeoutException: The request channel
timed out attempting to send after 00:00:19.8689925. Increase the
timeout value passed to the call to Request or increase the
SendTimeout value on the Binding. The time allotted to this operation
may have been a portion of a longer timeout
The channel connection is secured with var binding = new WSHttpBinding("SecureWsHttpBinding") and Certificates.
I have tried with various increasing OperationTimeout values from 60s to 120s with basically the same result.
At the time when the Exception occur the network card is up and running.
Do anybody know why this is happening under these conditions? Do SecureWsHttpBinding require some windows services to run?
We have a service implmented in WCF. It works fine in all environment except in a particular environment it often throws below exception
System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (502) Bad Gateway.
System.Net.WebException: The remote server returned an error: (502) Bad Gateway. at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)...
The called methods return a Boolean value. But it is a big transaction which takes time on DB end often 15 mins. Our configuration is done for 50 mins.
Sometime is completes the transaction. Sometime it throws above error just after 2 minutes.
On the target machine there are load balancers involve. I have doubt that is error is because of them.
If the reason is so.. then what are my options??
I'm trying to move big bunch of messages to another folder and the operation take approximately 5-8 minutes depends of the servers' locations and amount of items to move.
And I always get an error (504) Gateway Timeout,
with the stack trace:
Microsoft.Exchange.WebServices.Data.ServiceRequestException: The request failed. The remote server returned an error: (504) Gateway Timeout. ---> System.Net.WebException: The remote server returned an error: (504) Gateway Timeout.
at System.Net.HttpWebRequest.GetResponse()
at Microsoft.Exchange.WebServices.Data.EwsHttpWebRequest.Microsoft.Exchange.WebServices.Data.IEwsHttpWebRequest.GetResponse()
at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request)
--- End of inner exception stack trace ---
at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request)
at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(IEwsHttpWebRequest& request)
at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalMoveItems(IEnumerable`1 itemIds, FolderId destinationFolderId, Nullable`1 returnNewItemIds, ServiceErrorHandling errorHandling)
at Microsoft.Exchange.WebServices.Data.ExchangeService.MoveItems(IEnumerable`1 itemIds, FolderId destinationFolderId)
at EAS.Exchange.ExchangeProvider.MoveItemsToFolder(String folderUniqueId, String[] itemUniqueIds)
I was trying to increase timeout for ExchangeService:
var ews = new Microsoft.Exchange.WebServices.Data.ExchangeService();
ews.Timeout = 900000; // 15 minutes in milliseconds
but it doesn't solve the problem. By the way, the operation finishes successfully on the EWS and all the items are moved after that.
Could you please recommend another possible solution how to fix this issue?
The 504 error indicates that the remote server experienced a timeout. If you experienced a direct timeout, after all, then nothing would have had a chance to send back an HTTP status code.
So the issue is not due to the connection between your program and the Exchange service; the problem is due to one of the following:
A connection is timing out between the Exchange service and some other service that Exchange uses internally. You will need to figure out which component is timing out and adjust the timeout settings specific to that area of the system. There are a lot of timeouts to look at. You could start here.
Your access to the Exchange service is mediated by a proxy server, and the connection between the proxy server and Exchange is timing out. You may need to adjust the proxy server settings.
You may be able to determine which of the above is the issue by inspecting the W3C logs and searching for 504s. Or you may be able to tell what a 504 looks like when it comes from the proxy simply by its styling, depending on how you have things set up. Another possibility is to add the Exchange server's address to your proxy exclusion list and see if that has any effect.
I've set up Windows Server Service Bus 1.0 on a VM running Windows Server 2008 R2 Datacenter.
I've written a console application to send and receive messages to and from it and this works well.
I've been sending messages of increasing size successfully but the console app currently falls over when getting to 5,226,338 bytes (5,226,154 bytes message body + 184 bytes header I believe) which is just under 5MB. Ideally we need a bit more room to play with.
Some of the stack trace is as below...
Unhandled Exception:
Microsoft.ServiceBus.Messaging.MessagingCommunicationException: The
socket connection was aborted. This could be caused by an error
processing your message or a receive timeout being exceeded by the
remote host, or an underlying network resource issue. Local socket
timeout was '00:01:09.2720000'. - -->
System.ServiceModel.CommunicationException: The socket connection was
aborted. This could be caused by an error processing your message or a
receive timeout being exceeded by the remote host, or an underlying
network resource issue. Local socket timeout was '00:01:09.2720000'.
---> System.IO.IOException: The write operation failed, see inner exception. ---> System.ServiceModel.CommunicationException: The socket
connection was aborted. This could be caused by an error processing
your message or a receive timeout being exceeded by the remote host,
or an underlying network resource issue. Local socket timeout was
'00:01:09.2720000' . ---> System.Net.Sockets.SocketException: An
established connection was aborted by the software in your host
machine
The Windows Azure Service Bus apparently has a fixed limit of 256KB but the on premise Windows Server Service Bus has a limit of 50MB. See the articles below.
Mention of the Azure limit of 256KB - http://msdn.microsoft.com/en-us/library/windowsazure/hh694235.aspx
Mention of 50MB - http://msdn.microsoft.com/en-us/library/windowsazure/jj193026.aspx
I'm struggling to achieve the 50MB limit and would like to know if there is something I need to do to configure this somehow or perhaps the message needs to be sent in a certain way. I noticed there was a parameter name in the above article and wondered if that could be used in PowerShell.
I've struggled to find some good information on this online. There is much confusion out there with some articles relating to Azure Service Bus but others relating to Windows Server Service Bus.
There is Service Bus 1.1 but I think this is in preview at the moment and I'm not sure this will help.
I am using code similar to the below to send the message.
namespaceManager = NamespaceManager.Create();
messagingFactory = MessagingFactory.Create();
queueClient = messagingFactory.CreateQueueClient(queueName);
queueClient.Send(new BrokeredMessage(new string('x', 5226154)));
This was taken from a combination of the articles below, the first one being slightly outdated and second one making it slightly clearer what needed to be changed in order to get things working.
http://haishibai.blogspot.co.uk/2012/08/walkthrough-setting-up-development.html
http://msdn.microsoft.com/en-us/library/windowsazure/jj218335(v=azure.10).aspx
I hope someone can help.
I've had the same problem but I have figured it out after few tries.
Just open file
C:\Program Files\Service Bus\1.1\Microsoft.ServiceBus.Gateway.exe.config
and change nettcp binding with name netMessagingProtocolHead set
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
and restart all service bus services.
Now I'am able to send and receive message with size new string('A', 49 * 1024 * 1024).
Enjoy :-)
Martin
The exception you're getting is a timeout, so your best bet is probably to fine tune your timeouts a little bit. Have you tried setting the client side timeout to a higher value? You can do that via the MessagingFactorySettings object. Also, have you checked the server side logs to see if anything there gives you a clue?
The parameter you mention is to set a quota. When you send a message that it's bigger than the quota it should be immediately rejected. In your case, the message is being accepted, but it is apparently timing out when in transit.
I have a problem with wcf servcices.
Wcf services method is inovked by an application. This app calls service method very often (dozens of times per minute). The service method is called properly (with Close() at the end, or Abort() after exception). The most strange thing for me is that after few hours my app is getting errors from services:
An error occurred while receiving the HTTP response to http://domain.xx/MyService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details. The underlying connection was closed: An unexpected error occurred on a receive. Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
or this one:
*The request channel timed out while waiting for a reply after 00:15:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout. The HTTP request to 'http://domain.xx/MyService.svc' has exceeded the allotted timeout of 00:15:00. The time allotted to this operation may have been a portion of a longer timeout. The operation has timed out *
What can couse such errors? Why services are working properly within few first hours?
I would check your application log. From my experience, those errors tend to me more server related than code related. IIS may be having problems.
I know you mentioned it but it looks your are not closing your channels right. Also, make sure you do NOT use the same client for many server calls. Just create one, use it for a single call, and dispose it.
Here's a good read about closing WCF channels.