msgpack-rpc-cli
msgpack-rpc-cli copied to clipboard
The client hangs after multiple calls
I tried a server implementations like this:
import msgpackrpc
class TestServer(object):
def Add(self, a, b):
print("Add({}, {}) called".format(a, b))
return a + b
def Mul(self, a, b):
print("Mul({}, {}) called".format(a, b))
return a * b
server = msgpackrpc.Server(TestServer())
server.listen(msgpackrpc.Address("localhost", 8070))
server.start()
The client looked like this:
public partial class Form1 : Form
{
private RpcClientConfiguration _clientConfig = new RpcClientConfiguration();
private dynamic _rpcProxy;
public Form1()
{
InitializeComponent();
_rpcProxy = new DynamicRpcProxy(new DnsEndPoint("127.0.0.1", 8070), _clientConfig);
}
~Form1()
{
_rpcProxy.Dispose();
}
private void btnAdd_Click(object sender, EventArgs e)
{
for (int i = 0; i < 50; ++i)
{
var result = (int) _rpcProxy.Add(Convert.ToInt32(i), Convert.ToInt32(tbB.Text));
lblResult.Text = String.Format("Result: {0}", result);
Thread.Sleep(100);
}
}
private void btnMul_Click(object sender, EventArgs e)
{
var result = (float)_rpcProxy.Mul(Convert.ToSingle(tbA.Text), Convert.ToSingle(tbB.Text));
lblResult.Text = String.Format("Result: {0}", result);
}
}
(I also tried a C++ server implementation but I'll omit that for brevity; I had the same results with it.)
What happens is after the 10th or so call the application hangs. It always hangs on this line: https://github.com/yfakariya/msgpack-rpc-cli/blob/master/src/MsgPack.Rpc.Client/Rpc/Client/AsyncResult.cs#L224
I does not matter how much I wait between the calls, it can even be as long as two seconds per call. Am I doing something wrong with the client or is this a bug?
Confirming the issue, but cant track down the problem... looks like some blocking queue overflow
Detailed tracing points that var responseContext = this.Manager.GetResponseContext( this, context.RemoteEndPoint ); at ClientTransport::OnSent locks because the object pool is empty at borrowing!
Created pull request (#5) about this issue
Sorry, I found the design bug that ResponseContext
is not reused correctly, so it leads pool exhausion.
So we should add the mechanism to reuse the ResponseContext
when we have established session to the server.
Hi, Just wanted to drop by and say that I really appreciate that you are working to solve this bug. Thanks!
@yfakariya Does the pull request of Skydev0h solve the issue?