Hi,
I write msgpack-rpc-d which depends on vibe.d.
One user reports client is blocked when RPC server returns 4096+ response.
OK: client sends 4096+ request to server.
In this point, this leastSize
returns entire request body size. So server can process the request correctly.
NG: server sends 4096+ response to client.
On the other hand, this leastSize
returns 4096 if response body size is 4096+.
I changed the code to like below but leastSize
is blocked when there is no remaining data.
ubyte[] result;
do {
auto size = input.leastSize;
if (size == 0) {
proccessRequest(result);
break;
}
ubyte[] data = new ubyte[](size);
input.read(data);
result ~= data;
} while (_connection.connected);
I tried "dataAvailableForRead" method but this method always returns false
.
msgpack-rpc is a binary based protocol and doesn't have a request size header.
Establishing new connection in each request can avoid this problem but it is high cost.
How to handle above case in vibe.d?
I tested this code with dmd 2.066.0, vibe.d 0.7.21-rc.3, libevent 2.0.0+2.0.16.
Thanks!