How to create multiple TCP connection and break a TCP connection?

63 views
Skip to first unread message

xia rui

unread,
Aug 19, 2019, 11:11:28 PM8/19/19
to grpc.io
Hello everyone.
I am using gRPC to build a simple client-server application. In the client side, I start multiple threads to send requests to a server (target is an identical gRPC call). In the server side, it opens a socket (localhost:50051) and waits for requests.

Now, I create three request sending worker-threads at the client. But, ONLY one TCP connection is setup. My first problem is Is it possible that each worker-thread sets up a sole TCP connection?

During the whole sending procedure, I find there is no new TCP connection. So the TCP connection is set up only once. My second problem is Is it possible to break an old TCP connection and re-connection it?

Thank you for your time.

Best wishes,
Xia Rui

Thomas Mercier

unread,
Aug 20, 2019, 1:26:15 AM8/20/19
to xia rui, grpc.io
Hi,

This is what you want for problem 1:

ChannelArguments args;
args.SetInt(GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL, 1);

Easiest way to cycle a connection is probably to destroy the stub and make a new one.


You probably want none of this for performance.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/608abe11-17cd-4bf2-8712-625a3598b60e%40googlegroups.com.

xia rui

unread,
Aug 20, 2019, 1:46:38 AM8/20/19
to grpc.io
Thank you for the helpful suggests. 

On Tuesday, August 20, 2019 at 1:26:15 PM UTC+8, Thomas Mercier wrote:
Hi,

This is what you want for problem 1:

ChannelArguments args;
args.SetInt(GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL, 1);

Easiest way to cycle a connection is probably to destroy the stub and make a new one.


You probably want none of this for performance.

On Mon, Aug 19, 2019 at 8:11 PM xia rui <xiaru...@gmail.com> wrote:
Hello everyone.
I am using gRPC to build a simple client-server application. In the client side, I start multiple threads to send requests to a server (target is an identical gRPC call). In the server side, it opens a socket (localhost:50051) and waits for requests.

Now, I create three request sending worker-threads at the client. But, ONLY one TCP connection is setup. My first problem is Is it possible that each worker-thread sets up a sole TCP connection?

During the whole sending procedure, I find there is no new TCP connection. So the TCP connection is set up only once. My second problem is Is it possible to break an old TCP connection and re-connection it?

Thank you for your time.

Best wishes,
Xia Rui

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grp...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages