Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The client hangs after multiple calls #4

Open
sztomi opened this issue Mar 17, 2015 · 6 comments
Open

The client hangs after multiple calls #4

sztomi opened this issue Mar 17, 2015 · 6 comments

Comments

@sztomi
Copy link

sztomi commented Mar 17, 2015

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?

@Skydev0h
Copy link

Skydev0h commented Jun 4, 2015

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

@Skydev0h
Copy link

Skydev0h commented Jun 4, 2015

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
Copy link

Skydev0h commented Jun 4, 2015

Created pull request (#5) about this issue

@yfakariya
Copy link
Owner

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.

@sztomi
Copy link
Author

sztomi commented Jun 18, 2015

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

@timmi-on-rails
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants