Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a single netty bootstrap connect to multiple hosts

Tags:

netty

Is it possible to use a single clientsocketbootstrap to connect to multiple hosts? Also, does each connection get its own pipeline, so one connection can have a certain set of handlers and another its own set of handlers?

bootstrap.connect(serverA, portA);

then, later, after serverA is connected,

bootstrap.connect(serverB, portB);

like image 667
R. Andrews Avatar asked Dec 07 '25 03:12

R. Andrews


2 Answers

Yes you can reuse the client bootstrap without a problem. If you specify a ChannelPipelineFactory each new channel will get its own ChannelPipeline. If you want to have different settings for different clients you may just create one client bootstrap per connection. This works out very well as the bootstrap is really light-weight.

like image 178
Norman Maurer Avatar answered Dec 09 '25 17:12

Norman Maurer


Take a look at this answer. It shows the code to use same client bootstrap with different handlers, creating multiple connections.

like image 34
Abe Avatar answered Dec 09 '25 15:12

Abe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!