NullReferenceException after calling HttpRequest.GetResponse()

0 votes
asked Aug 5 by mobile653 (300 points)

Using the Rebex HTTPS library version 2018R4 on .NET Compact Framework 3.5 we got some NullReferenceExceptions with the following Stack:

System.NullReferenceException: NullReferenceException
at Rebex.Net.HttpRequest.edna()
at Rebex.Net.HttpRequest.edmz()
at Rebex.Net.HttpRequest.GetResponse()
at [our code]

This should not happen, right?
Could this be already fixed in a later version? (Can’t find anything about this in your release notes.)

Thanks

2 Answers

0 votes
answered Aug 5 by Lukas Pokorny (102,170 points)

Yes, this should not happen, at least unless you call multiple methods or properties of a single HttpRequest instance from multiple threads at the same time. See more information on .NET's WebRequest that applies to HttpRequest as well.

Please check your application and let us know whether this could be the reason or not.

If you don't call multiple methods or properties on a single HttpRequest instance (at the same time), a NullReferenceException should never occur in GetResponse method, so this exception would indicate a yet-unknown bug in Rebex HTTPS (which we would aim to fix as soon as possible).

0 votes
answered Aug 20 by mobile653 (300 points)

We have examined our code and found no evidence of a multiple usage of a HttpRequest instance. The object is created using

var request = (HttpRequest)WebRequest.Create(URL);

and the command leading to the Exception

var response = (HttpResponse)request.GetResponse();

is only called once. The finally block looks like this:

…
} finally {
    if (request != null) {
        request.Abort();
    }
    request = null;
}

Maybe we have created multiple HttpRequest instances with the same URL in parallel, but those ones should not interfere, right?

commented Aug 21 by Lukas Pokorny (102,170 points)
Multiple instances of HttpRequest with the same URL should not interfere, but they do share some internal objects (we do HTTP session caching in a manner similar to .NET's HttpWebRequest), so there might be a bug in there. In order to further investigate this, please do the following:
1. Try using the latest version of Rebex HTTPS (2019 R3.1) and let us know if the issue still persists.
2. If it does, create a communication log showing the context of the error (see https://www.rebex.net/kb/logging/ for instructions) and post it here or mail it to us for analysis.
3. We were unable to match your forum account to any license purchase in our database. Please contact support@rebex.net and provide an order number so we can fix this. Thanks!
...