views:

49

answers:

2

I have a Web service hosted in IIS in different box and WCF service hosted in Windows service, in a different box.(N-tier approach). Here, Web service is a client for WCF service. The request to upload the file comes to the IIS hosted Web service, and this IIS hosted Web service in return calls the WCF service and does the actual upload. So far so good. After the upload is done the WCF service performs the callback (I have stored the callbacks in dictionary, and I have used (InstanceContextMode=InstanceContextMode.PerSession, ConcurrencyMode=ConcurrencyMode.Multiple)). The WCF service sends the callback. In the trace viewer, it looks like the ASP.NET received the callback, but the upload page in browser(this is the end user) freezes for good. I am using ChunkingChannel binding by larsw.

First of all, is it at all possible to implement the above senario, as John Saundars mentioned in this link:

http://stackoverflow.com/questions/3171405/what-does-operationcontext-current-getcallbackchannel-actually-do

Thanks for the help.

A: 

Not sure what you mean by "freezes", is this just that it does not update or that it becomes unresponsive.

It may be that the response for the asp page is sent to the browser before the response comes back to the web server from the wcf service. In this case the asp page will not get updated when the result comes back from the service.

You have 2 options:

  • Use javascript to poll the server for changes.
  • Block the return of the upload page untill the response is received from the service.

If you endup waiting for the call back, then it would be simpler just to do a request response style.

Another common probliem is that the wcf proxy on the client gets closed before the callback is received. The trace would show it coming back, but nobody is listening.

Shiraz Bhaiji
A: 

Hi Shiraz.

It is weired, I restarted the computer and now am getting the following in Trace viewer in the client (ASP.NET) side, and also the page doesn't freezes(unresponsive) now. The message that most concerns me is its inner exception: System.NullReferenceException, mscorlib and says Object reference not...

I tried with Console Application as a client to WCF Service. The callback works great. It is only when I host my website in IIS and call WCF service to upload file(which in return calls back to the client to notify that the upload was/not successful).

(I am using HttpChunkingBinding). Any idea?

System.Runtime.FatalException, System.Runtime.DurableInstancing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 Object reference not set to an instance of an object. at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet) at System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(RequestContext request, Boolean cleanThread, OperationContext currentOperationContext) at System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext request, OperationContext currentOperationContext) at System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult result) at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result) at System.ServiceModel.Diagnostics.TraceUtility.<>c_DisplayClass4.<CallbackGenerator>b_2(AsyncCallback callback, IAsyncResult result) at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously) at System.Runtime.InputQueue1.AsyncQueueReader.Set(Item item) at System.Runtime.InputQueue1.Dispatch() at System.ServiceModel.Channels.ReliableDuplexSessionChannel.ProcessDuplexMessage(WsrmMessageInfo info) at System.ServiceModel.Channels.ReliableDuplexSessionChannel.HandleReceiveComplete(IAsyncResult result) at System.ServiceModel.Channels.ReliableDuplexSessionChannel.OnReceiveCompletedStatic(IAsyncResult result) at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result) at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously) at System.ServiceModel.Channels.ReliableChannelBinder1.InputAsyncResult1.OnInputComplete(IAsyncResult result) at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result) at System.ServiceModel.Diagnostics.TraceUtility.<>c_DisplayClass4.<CallbackGenerator>b_2(AsyncCallback callback, IAsyncResult result) at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously) at System.Runtime.InputQueue1.AsyncQueueReader.Set(Item item) at System.Runtime.InputQueue1.Dispatch() at System.Runtime.ActionItem.DefaultActionItem.Invoke() at System.Runtime.ActionItem.CallbackHelper.InvokeWithoutContext(Object state) at System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped) at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped) at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP) System.Runtime.FatalException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at System.Web.HttpApplication.ThreadContext.Enter(Boolean setImpersonationContext) at System.Web.HttpApplication.OnThreadEnterPrivate(Boolean setImpersonationContext) at System.Web.AspNetSynchronizationContext.CallCallbackPossiblyUnderLock(SendOrPostCallback callback, Object state) at System.Web.AspNetSynchronizationContext.CallCallback(SendOrPostCallback callback, Object state) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) --- End of inner exception stack trace --- at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet) at System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(RequestContext request, Boolean cleanThread, OperationContext currentOperationContext) at System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext request, OperationContext currentOperationContext) at System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult result) at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result) at System.ServiceModel.Diagnostics.TraceUtility.<>c_DisplayClass4.<CallbackGenerator>b_2(AsyncCallback callback, IAsyncResult result) at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously) at System.Runtime.InputQueue1.AsyncQueueReader.Set(Item item) at System.Runtime.InputQueue1.Dispatch() at System.ServiceModel.Channels.ReliableDuplexSessionChannel.ProcessDuplexMessage(WsrmMessageInfo info) at System.ServiceModel.Channels.ReliableDuplexSessionChannel.HandleReceiveComplete(IAsyncResult result) at System.ServiceModel.Channels.ReliableDuplexSessionChannel.OnReceiveCompletedStatic(IAsyncResult result) at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result) at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously) at System.ServiceModel.Channels.ReliableChannelBinder1.InputAsyncResult1.OnInputComplete(IAsyncResult result) at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result) at System.ServiceModel.Diagnostics.TraceUtility.<>c_DisplayClass4.<CallbackGenerator>b_2(AsyncCallback callback, IAsyncResult result) at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously) at System.Runtime.InputQueue1.AsyncQueueReader.Set(Item item) at System.Runtime.InputQueue1.Dispatch() at System.Runtime.ActionItem.DefaultActionItem.Invoke() at System.Runtime.ActionItem.CallbackHelper.InvokeWithoutContext(Object state) at System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped) at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped) at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP) System.NullReferenceException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Object reference not set to an instance of an object. at System.Web.HttpApplication.ThreadContext.Enter(Boolean setImpersonationContext) at System.Web.HttpApplication.OnThreadEnterPrivate(Boolean setImpersonationContext) at System.Web.AspNetSynchronizationContext.CallCallbackPossiblyUnderLock(SendOrPostCallback callback, Object state) at System.Web.AspNetSynchronizationContext.CallCallback(SendOrPostCallback callback, Object state) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) System.NullReferenceException: Object reference not set to an instance of an object. at System.Web.HttpApplication.ThreadContext.Enter(Boolean setImpersonationContext) at System.Web.HttpApplication.OnThreadEnterPrivate(Boolean setImpersonationContext) at System.Web.AspNetSynchronizationContext.CallCallbackPossiblyUnderLock(SendOrPostCallback callback, Object state) at System.Web.AspNetSynchronizationContext.CallCallback(SendOrPostCallback callback, Object state) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)

MS_Windows
Well, the issue is resolved by Allen Chen - MSFT. http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/5edef384-eb64-4430-990f-fc149d40cb21/#4f93edd3-36a6-43a3-96b2-969b5903f563
MS_Windows