none
WCF - The remote server returned an error: (500) Internal Server Error.

    Question

  • Hello,

    I have a .NET 4.0 Windows client that is consuming a WCF service that is hosted in IIS7 on a Windows Server 2008 Standard machine.

    My Windows client application calls the WCF service to perform database synchronization.  The process can take some time depending on the amount of data that is being synchronized.

    After about 3 minutes and 15 seconds, I receive the following exception:

    Exception Type: System.ServiceModel.ProtocolException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    Message: "The connection to the website was closed by the site or by one of its servers"
    Inner Exception Type: System.Net.WebException, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    Inner Exception Message: "The remote server returned an error: (500) Internal Server Error."

    I can't figure out what is wrong.  I have tried the following:

    1. In IIS > my site > feature view > Error Pages > select 500 error > edit > selected detail error. Nothing extra was shown.
    2. Enabled WCF tracing on the server and the client.  Server trace log didn't produce any errors and the client trace log generated the error noted above
    3. Increased the following WCF timeout values to 15 minutes for both the server and client: closeTimeout, openTimeout, receiveTimeout, sendTimeout
    4. Checked Event Viewer on the server for any errors, didn't find anything
    5. I can browse to the service in IE, and the everything works fine when there isn't a lot of data to sync.  With this exception, I am trying to sync around 3MB of data

    Does anyone have any sugguestions on how I can find a solution for this exception?  The configuration file and call stack are included below for completeness.

    Thanks in advance for your help.

    Garry

    Client App.Config

    <binding name="BasicHttpBinding_ISyncService" closeTimeout="00:15:00"
    	openTimeout="00:15:00" receiveTimeout="00:15:00" sendTimeout="00:15:00"
    	allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
    	maxBufferSize="62914560" maxBufferPoolSize="62914560" maxReceivedMessageSize="62914560"
    	messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
    	useDefaultWebProxy="true">
    	<readerQuotas maxDepth="32" maxStringContentLength="62914560"
    		maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
    	<security mode="TransportCredentialOnly">
    		<transport clientCredentialType="Ntlm" proxyCredentialType="None"
    			realm="" />
    		<message clientCredentialType="UserName" algorithmSuite="Default" />
    	</security>
    </binding>
    

    Server Web.Config

    <binding name="BasicHttpBinding_SyncService" closeTimeout="00:15:00" openTimeout="00:15:00" receiveTimeout="00:15:00" sendTimeout="00:15:00" maxBufferSize="62914560" maxBufferPoolSize="62914560" maxReceivedMessageSize="62914560">
    	<readerQuotas maxStringContentLength="62914560" />
    	<security mode="TransportCredentialOnly">
    		<transport clientCredentialType="Ntlm" />
    	</security>
    </binding>
    

    Call Stack of outter exception

    System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
    System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
    System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
    System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
    System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
    System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
    System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData, Int32 type)
    Agora.RT.Win.Sync.SyncService.ISyncService.ApplyChanges(SyncGroupMetadata groupMetadata, DataSet dataSet, SyncSession syncSession)
    Agora.RT.Win.Sync.SyncService.SyncServiceClient.ApplyChanges(SyncGroupMetadata groupMetadata, DataSet dataSet, SyncSession syncSession)
    System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct&amp; sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
    System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
    System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
    System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
    Microsoft.Synchronization.Data.ServerSyncProviderProxy.ApplyChanges(SyncGroupMetadata groupMetadata, DataSet dataSet, SyncSession syncSession)
    Microsoft.Synchronization.SyncAgent.UploadChanges(SyncGroupMetadata groupMetadata)
    Microsoft.Synchronization.SyncAgent.DataSynchronize()
    Microsoft.Synchronization.SyncAgent.Synchronize()
    Agora.RT.Win.Form_Main.Synchronize()
    System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]&amp; outArgs)
    System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
    System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.DoAsyncCall()
    System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(Object o)
    System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
    System.Threading.ExecutionContext.runTryCode(Object userData)
    System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
    System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
    System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
    System.Threading.ThreadPoolWorkQueue.Dispatch()
    System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
    

    Call Stack of inner exception

    System.Net.HttpWebRequest.GetResponse()
    System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
    
    Wednesday, October 27, 2010 1:00 AM

Answers

  • Hi,

    It's strange that you could not get any error log from WCF tracing. Are you sure you set config correctly at server side? Please use the setting mentioned in the following article to confirm that.

    http://blogs.msdn.com/govindr/archive/2006/11/01/debugging-wcf-traces-and-message-logs.aspx

    If you are not able to see any error logs at server side my guess is the error message is returned from a middle node. Are you using proxy?


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. Windows Azure Platform China Blog: http://blogs.msdn.com/azchina/default.aspx
    Tuesday, November 02, 2010 6:29 AM
    Moderator

All replies