Nullreference exception in Asynchronous webservice call (.Net 2.0)

Discussion in 'ASP .Net Web Services' started by vecozo@online.nospam, Jun 29, 2006.

  1. Guest

    [this has previously been posted buy raymondr at Nullreference exception in
    Asynchronous webservice call (.Net 2.0)]


    Hi,

    First a brief description of out application:
    We have a webapplication which calls a couple of webservices during one
    request (postback). These calls to the webservices are made concurrent using
    asynchronous webservices calls. The number of webservices called concurrent
    is between 1 and 18.
    The webservice calls are made using SSL with a X509 clientcertificate.
    The application is underhigh load

    The problem:
    After migration to the .Net Framework 2.0 we once in a while get a
    nullreferenceexception during the asynchronous call. The exception seems to
    occur somewhere in the framework. It only occurs on our production
    environment.

    Maybe someone got a clue? See the stacktrace below

    The stacktrace is :
    NullreferenceException
    at
    System.Web.Services.Protocols.WebClientProtocol.ReadAsyncResponse(WebClientAsyncResult client)
    at
    System.Web.Services.Protocols.WebClientProtocol.GetResponseAsyncCallback(IAsyncResult asyncResult)
    at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
    at System.Net.ContextAwareResult.CompleteCallback(Object state)
    at System.Threading.ExecutionContext.runTryCode(Object userData)
    at
    System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext
    executionContext, ContextCallback callback, Object state)
    at System.Threading.ExecutionContext.Run(ExecutionContext
    executionContext, ContextCallback callback, Object state)
    at System.Net.ContextAwareResult.Complete(IntPtr userToken)
    at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result,
    IntPtr userToken)
    at System.Net.HttpWebRequest.SetResponse(Exception E)
    at System.Net.HttpWebRequest.CheckWriteSideResponseProcessing()
    at System.Net.ConnectStream.ProcessWriteCallDone(ConnectionReturnResult
    returnResult)
    at System.Net.HttpWebRequest.WriteCallDone(ConnectStream stream,
    ConnectionReturnResult returnResult)
    at System.Net.ConnectStream.CallDone(ConnectionReturnResult returnResult)
    at System.Net.ConnectStream.ResubmitWrite(ConnectStream oldStream,
    Boolean suppressWrite)
    at System.Net.HttpWebRequest.EndWriteHeaders_Part2()
    at System.Net.HttpWebRequest.EndWriteHeaders(Boolean async)
    at System.Net.HttpWebRequest.WriteHeadersCallback(WebExceptionStatus
    errorStatus, ConnectStream stream, Boolean async)
    at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
    at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
    at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result,
    IntPtr userToken)
    at System.Net.Security._SslStream.StartWriting(Byte[] buffer, Int32
    offset, Int32 count, AsyncProtocolRequest asyncRequest)
    at System.Net.Security._SslStream.WriteCallback(IAsyncResult
    transportResult)
    at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
    at System.Net.ContextAwareResult.CompleteCallback(Object state)
    at System.Threading.ExecutionContext.runTryCode(Object userData)
    at
    System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext
    executionContext, ContextCallback callback, Object state)
    at System.Threading.ExecutionContext.Run(ExecutionContext
    executionContext, ContextCallback callback, Object state)
    at System.Net.ContextAwareResult.Complete(IntPtr userToken)
    at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result,
    IntPtr userToken)
    at
    System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32
    errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
    at
    System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32
    errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

    Best Regards,
    Raymond

    www.VECOZO.nl
    , Jun 29, 2006
    #1
    1. Advertising

  2. Hello Raymond,

    I never saw similiar issue reported before. Did the exception always occur
    with one web service\web method, or totally random? Can it be repeated
    after you find one in the system?

    Regards,

    Luke Zhang
    Microsoft Online Community Lead

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    Luke Zhang [MSFT], Jun 30, 2006
    #2
    1. Advertising

  3. Simon Hart Guest

    You could try and register the AppDomain.UnhandledException and capture the
    NullReference exception to see if it gives you any more clues.

    Also ensure when you call the End method of the web service proxy class, the
    IAsyncResult object is not null.

    Regards
    Simon.

    <> wrote in message
    news:...
    > [this has previously been posted buy raymondr at Nullreference exception
    > in
    > Asynchronous webservice call (.Net 2.0)]
    >
    >
    > Hi,
    >
    > First a brief description of out application:
    > We have a webapplication which calls a couple of webservices during one
    > request (postback). These calls to the webservices are made concurrent
    > using
    > asynchronous webservices calls. The number of webservices called
    > concurrent
    > is between 1 and 18.
    > The webservice calls are made using SSL with a X509 clientcertificate.
    > The application is underhigh load
    >
    > The problem:
    > After migration to the .Net Framework 2.0 we once in a while get a
    > nullreferenceexception during the asynchronous call. The exception seems
    > to
    > occur somewhere in the framework. It only occurs on our production
    > environment.
    >
    > Maybe someone got a clue? See the stacktrace below
    >
    > The stacktrace is :
    > NullreferenceException
    > at
    > System.Web.Services.Protocols.WebClientProtocol.ReadAsyncResponse(WebClientAsyncResult
    > client)
    > at
    > System.Web.Services.Protocols.WebClientProtocol.GetResponseAsyncCallback(IAsyncResult
    > asyncResult)
    > at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
    > at System.Net.ContextAwareResult.CompleteCallback(Object state)
    > at System.Threading.ExecutionContext.runTryCode(Object userData)
    > at
    > System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode
    > code, CleanupCode backoutCode, Object userData)
    > at System.Threading.ExecutionContext.RunInternal(ExecutionContext
    > executionContext, ContextCallback callback, Object state)
    > at System.Threading.ExecutionContext.Run(ExecutionContext
    > executionContext, ContextCallback callback, Object state)
    > at System.Net.ContextAwareResult.Complete(IntPtr userToken)
    > at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result,
    > IntPtr userToken)
    > at System.Net.HttpWebRequest.SetResponse(Exception E)
    > at System.Net.HttpWebRequest.CheckWriteSideResponseProcessing()
    > at System.Net.ConnectStream.ProcessWriteCallDone(ConnectionReturnResult
    > returnResult)
    > at System.Net.HttpWebRequest.WriteCallDone(ConnectStream stream,
    > ConnectionReturnResult returnResult)
    > at System.Net.ConnectStream.CallDone(ConnectionReturnResult
    > returnResult)
    > at System.Net.ConnectStream.ResubmitWrite(ConnectStream oldStream,
    > Boolean suppressWrite)
    > at System.Net.HttpWebRequest.EndWriteHeaders_Part2()
    > at System.Net.HttpWebRequest.EndWriteHeaders(Boolean async)
    > at System.Net.HttpWebRequest.WriteHeadersCallback(WebExceptionStatus
    > errorStatus, ConnectStream stream, Boolean async)
    > at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
    > at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
    > at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result,
    > IntPtr userToken)
    > at System.Net.Security._SslStream.StartWriting(Byte[] buffer, Int32
    > offset, Int32 count, AsyncProtocolRequest asyncRequest)
    > at System.Net.Security._SslStream.WriteCallback(IAsyncResult
    > transportResult)
    > at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
    > at System.Net.ContextAwareResult.CompleteCallback(Object state)
    > at System.Threading.ExecutionContext.runTryCode(Object userData)
    > at
    > System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode
    > code, CleanupCode backoutCode, Object userData)
    > at System.Threading.ExecutionContext.RunInternal(ExecutionContext
    > executionContext, ContextCallback callback, Object state)
    > at System.Threading.ExecutionContext.Run(ExecutionContext
    > executionContext, ContextCallback callback, Object state)
    > at System.Net.ContextAwareResult.Complete(IntPtr userToken)
    > at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result,
    > IntPtr userToken)
    > at
    > System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32
    > errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
    > at
    > System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32
    > errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
    >
    > Best Regards,
    > Raymond
    >
    > www.VECOZO.nl
    >
    Simon Hart, Jun 30, 2006
    #3
  4. Raymondr Guest

    RE: Nullreference exception in Asynchronous webservice call (.Net

    Hello Luke,

    We concurrently call different webservices endpoints which have implemented
    the same wsdl. So it's always the same method but not the same webservice.
    If a webservice doesn't respond in the time given, the asynchronous call is
    aborted and the instance of the proxy class is disposed.

    We have multiple servers in our cluster. It happens on all multiple servers.
    The total number of requests made by our servers to the other webservers is
    between 10.000 and 150.000 per hour.

    Best Regards,

    Raymond
    "Luke Zhang [MSFT]" wrote:

    > Hello Raymond,
    >
    > I never saw similiar issue reported before. Did the exception always occur
    > with one web service\web method, or totally random? Can it be repeated
    > after you find one in the system?
    >
    > Regards,
    >
    > Luke Zhang
    > Microsoft Online Community Lead
    >
    > ==================================================
    > When responding to posts, please "Reply to Group" via your newsreader so
    > that others may learn and benefit from your issue.
    > ==================================================
    >
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    >
    Raymondr, Jun 30, 2006
    #4
  5. RE: Nullreference exception in Asynchronous webservice call (.Net

    Hell Raymond,

    You may implement some exception handling code (like
    AppDomain.UnhandledException as Simon suggested), record the server and web
    method it happened with. And check if the server is connectable at that
    time, or recall the web method, will it always failed if one exception
    occurred?

    Regards,

    Luke Zhang
    Microsoft Online Community Lead

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    Luke Zhang [MSFT], Jul 3, 2006
    #5
  6. RE: Nullreference exception in Asynchronous webservice call (.Net

    Hello Luke,

    The stacktrace in the first message is the Exception caught by the
    AppDomain.UnhandledException event. The IAsyncResult object is not null, the
    exception is not thrown in the End method of the webservice call.
    It occurs somewhere in the framework when handling the asynchronous call. In
    the exception is also not possible to detect which webservice is causing the
    error.

    Maybe this also did occure in the 1.1 framework but we didn't notice it
    because we didn't handle the uncaught exceptions. We changed the
    aspnet.config with legacyUnhandledExceptionPolicy enabled="true" so our
    worker process isn't recycled when this occurs (it happens approx. each 5
    minutes causing time out to our clients)

    I think there's a bug in handling the asynchronous result. If something went
    wrong with the webservice called I would expect this exception would be
    caught and thrown when the End method of the webservice is called. The call
    to the End Method is surrounded by a try/catch.
    The way it's working now the exception is thrown in a separate thread
    managed by the framework causing my application pool to crash.

    Best regards,

    Raymond Roelands
    "Luke Zhang [MSFT]" wrote:

    > Hell Raymond,
    >
    > You may implement some exception handling code (like
    > AppDomain.UnhandledException as Simon suggested), record the server and web
    > method it happened with. And check if the server is connectable at that
    > time, or recall the web method, will it always failed if one exception
    > occurred?
    >
    > Regards,
    >
    > Luke Zhang
    > Microsoft Online Community Lead
    >
    > ==================================================
    > When responding to posts, please "Reply to Group" via your newsreader so
    > that others may learn and benefit from your issue.
    > ==================================================
    >
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    >
    Raymond Roelands, Jul 6, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2FtIE1hcnRpbg==?=

    NullReference to Web Control in UserControl... please help!

    =?Utf-8?B?U2FtIE1hcnRpbg==?=, Mar 30, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    2,857
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    Mar 30, 2006
  2. Replies:
    0
    Views:
    504
  3. Boot2TheHead
    Replies:
    2
    Views:
    485
    Boot2TheHead
    Sep 6, 2007
  4. DispEventAdvise fails with 0x80040202

    NullReference Exception with HttpModule

    DispEventAdvise fails with 0x80040202, Mar 24, 2008, in forum: ASP .Net
    Replies:
    0
    Views:
    336
    DispEventAdvise fails with 0x80040202
    Mar 24, 2008
  5. René Preußler

    Asynchronous Call of WebService method within a WebService

    René Preußler, Oct 29, 2008, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    188
    René Preußler
    Oct 29, 2008
Loading...

Share This Page