'Error getting response stream (ReadDoneAsync2): ReceiveFailure'

Customer reported getting an error sometimes

'Error getting response stream (ReadDoneAsync2): ReceiveFailure'

He’s running HomeSeer using Mono on Linux (Raspberry PI), the error is dfinitely coming from Mono - ReadDoneAsync2 is from Mono source - meaning the request was sent, but zero reply received.

I’ve done quite a bit of Googling, quite a few people reported this error (starting from 2012), but coudn’t find any clue.

One suggestion I found - that every REST request should end with ‘/’, even before ‘?’ - i.e. “xxx/?xxx”.

Is that right? Does your firmware require ‘/’ at the end. Funny that on Windows nodody is getting this…

The user has the Bridge and two SBBs, the error is only happening with the Bridge.

No, it doesn’t. Do you happen to know what requests are failing in this way?

It’s not happening always, just sometimes, really hard to tell…

Interesting that after adding ‘/’ at the end of all requests - SBB devices don’t have this problem anymore.

But that’s according to the user. And only on Mono.

From Mono source code the error means that response was received, but with 0 bytes

Any ideas @jacob? The user says the problem is only with the Bond Bridge, not two SBB fans

In this instance it would be helpful to have a copy of the log from the Bridge (edit) unit. You can get it using the bond-cli program on our github, or even via the API (debug/livelog).

The other useful information would be the output of a cURL command, or the raw TCP stream like from Wireshark. The Mono errors don’t show the full picture. (And we are not Mono experts.)

As I said, SBBs are fine, the problem is with the Bridge only. And I don’t see how cURL might help.

The problem is that sometimes the socket read returns 0 bytes:

var nread = await RequestStream.InnerStream.ReadAsync (
					buffer.Buffer, buffer.Offset, buffer.Size, cancellationToken).ConfigureAwait (false);

if (nread == 0)
    throw GetReadException (WebExceptionStatus.ReceiveFailure, null, "ReadDoneAsync2");

And only with the Bridge, not SBBs.

I might dig deeper into ReadAsync() to see why it might return 0 bytes, but not timeout.

This is precisely why I asked you to reproduce the problem with cURL, or to show us a TCP stream. We cannot tell you the Mono side of things.

Oh and I meant to say Bridge above. Edited sorry for the mixup. (Good eye, @residualimages!)