Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
202 views
in Technique[技术] by (71.8m points)

Netty ProxyHandler - Retry Connect with Alternate Host

I'm trying to wrap my head around what would be the best way to retry the ProxyHandler.connect() with an alternate hostname if the connection fails for the first host.

My initial thought was to use an exceptionCaught() and listen for the cause ProxyConnectException but I then noticed that ProxyHandler.connect() is expecting a promise. I don't believe I have access to the original promise from within my exceptionCaught() and my fear is that constructing a new one at this point will break any further notifying down the pipeline.

Are my fears unfounded and am I OK to just call ProxyHandler.connect() with a new promise? Should I just reconstruct my own ProxyHandler so I can handle an alternate host directly in the connect()?

question from:https://stackoverflow.com/questions/65923195/netty-proxyhandler-retry-connect-with-alternate-host

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The suggestion made by @NormanMaurer to attach a ChannelFutureListener worked in my case. My theory of reworking the channel's pipeline wasn't appropriate though. I instead made my channel initializer aware of the alternate host and whether it needed to build the ProxyHandler using it. I believe I was overcomplicating everything when in reality I basically needed to do what @NormanMaurer had suggested here for connection retries.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...