msgpack-rpc-cli icon indicating copy to clipboard operation
msgpack-rpc-cli copied to clipboard

The client hangs after multiple calls

Open sztomi opened this issue 9 years ago • 6 comments

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?

sztomi avatar Mar 17 '15 15:03 sztomi

Confirming the issue, but cant track down the problem... looks like some blocking queue overflow

Skydev0h avatar Jun 04 '15 07:06 Skydev0h

Detailed tracing points that var responseContext = this.Manager.GetResponseContext( this, context.RemoteEndPoint ); at ClientTransport::OnSent locks because the object pool is empty at borrowing!

Skydev0h avatar Jun 04 '15 08:06 Skydev0h

Created pull request (#5) about this issue

Skydev0h avatar Jun 04 '15 22:06 Skydev0h

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.

yfakariya avatar Jun 14 '15 14:06 yfakariya

Hi, Just wanted to drop by and say that I really appreciate that you are working to solve this bug. Thanks!

sztomi avatar Jun 18 '15 13:06 sztomi

@yfakariya Does the pull request of Skydev0h solve the issue?

timmi-on-rails avatar Apr 26 '19 05:04 timmi-on-rails