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

Add remote address information in SessionProtocolNegotiationException #6113

Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,9 @@ private void connect(SessionProtocol desiredProtocol, SerializationFormat serial
notifyConnect(desiredProtocol, key,
eventLoop.newFailedFuture(
new SessionProtocolNegotiationException(
desiredProtocol, "previously failed negotiation")),
desiredProtocol,
"previously failed negotiation (remoteAddress: " +
remoteAddress + ')')),
promise, timingsBuilder);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ void finishWithNegotiationFailure(
final ChannelPipeline pipeline = ctx.pipeline();
pipeline.channel().eventLoop().execute(
() -> pipeline.fireUserEventTriggered(
new SessionProtocolNegotiationException(expected, actual, reason)));
new SessionProtocolNegotiationException(
expected, actual, reason + " (channel: " + pipeline.channel() + ')')));
ctx.close();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private void scheduleSessionTimeout(Channel channel, Promise<Channel> sessionPro
sessionTimeoutFuture = channel.eventLoop().schedule(() -> {
if (sessionPromise.tryFailure(new SessionProtocolNegotiationException(
desiredProtocol,
"connection established, but session creation timed out: " + channel))) {
"connection established, but session creation timed out. (channel: " + channel + ')'))) {
channel.close();
}
}, connectionTimeoutMillis, TimeUnit.MILLISECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,21 @@ void shouldRejectH2WithoutAlpn() {
.tlsCustomizer(b -> b.trustManager(cert.certificate()))
.build()) {

final BlockingWebClient client = WebClient.builder("h2://127.0.0.1:" + server.httpPort())
final String remote = "127.0.0.1";
final BlockingWebClient client = WebClient.builder("h2://" + remote + ":" + server.httpPort())
.factory(factory)
.build()
.blocking();

assertThatThrownBy(() -> client.get("/"))
.isInstanceOf(UnprocessedRequestException.class)
.hasCauseInstanceOf(SessionProtocolNegotiationException.class)
.hasMessageContaining("expected: h2, actual: h1, " +
"reason: unexpected protocol negotiation result");
.hasMessageContainingAll(
"expected: h2",
"actual: h1",
"reason: unexpected protocol negotiation result",
remote
);
}
}
}
Loading