0 votes
by (140 points)

Hi there, I'm very new to Rebex and am currently evaluating the HTTPS WebClient as a drop-in replacement for the dotNET classes. The main reason is to get away from system dependencies in the crypto stack that result in unfortunate compatibility issues (e.g. no common cipher suites, even on TLS1.2) with some hosts on some platforms. So I'm very excited to see that Rebex may offer this and so I need to test it out.

Anyway, what I've done is take the standard example code and perform a POST like so (uri is just a string holding the target URI, which in these examples uses HTTPS, and the "data" parameter is a NameValueCollection object from the System.Collections.Specialized namespace):


using (Rebex.Net.WebClient RebexWebClient = new Rebex.Net.WebClient())
{
   byte[] ResponseBytes = RebexWebClient.UploadValues(uri, data);
   string Response = Encoding.UTF8.GetString(ResponseBytes).Trim();
}

What I have found is that this very basic code is quite unreliable. The debugger (VS2019) throws: System.NullReferenceException: 'Object reference not set to an instance of an object.' on the line above where "UploadValues" is called.

The stacktrace from the Exception shows:

at Rebex.Net.HttpClientResponse.qrsp() at Rebex.Net.HttpResponse.GetResponseStream() at Rebex.Net.WebClient.fpon(HttpRequest fz) at Rebex.Net.WebClient.pihi.qcus(HttpRequest gy) at Rebex.Net.WebClient.fpor[e](Uri gh, String gi, Boolean gj, Func`2 gk) at Rebex.Net.WebClient.fpok(Uri ft, String fu, NameValueCollection fv) at Rebex.Net.WebClient.UploadValues(Uri uri, String method, NameValueCollection values) at Rebex.Net.WebClient.UploadValues(String uri, NameValueCollection values) at MyMethodInMyClass(...)

I'm completely stumped by this since there are no null references in the parameters I am passing, and this seems to be host-specific in some way, though so far during preliminary testing it seems to be random.

All I did was download the HTTPS trial version, install it, and start using it in a test project.

Any ideas?

Applies to: Rebex HTTPS

1 Answer

0 votes
by (70.2k points)

This is very weird.

I have located the Rebex.Net.HttpClientResponse.qrsp() method which raised the NullReferenceException - if I am correct, you are using Version 2020 R1.1, assemblies for .NET 4.0.

The method is very short and it uses only two objects: _response and _userResponseStream.
Both are marked as readonly and both are always initialized in the class constructor.

This method would/cannot never throw the NullReferenceException.

Also none of our automated tests reported this kind of failure.

I have tried your code with famous: https://httpbin.org/post
100 cycles, with and without attached debugger. However, I cannot reproduce the error.

I think that the issue can be related to VS2019 debugger.

Can you please try to run your test application without debugger?

If it still fails, can you please send us your test application + version of your VS2019 (see "About" page) to support@rebex.net?

...