0

我为此尝试,创建了一个新的连接器以尝试支持 h2c,当我尝试使用 curl 发送 http2 请求时,服务器发生错误;环境: springboot 2.1.4 tomcat 9 jdk 1.8

@Bean
public ServletWebServerFactory servletContainer() {
    TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
    tomcat.addAdditionalTomcatConnectors(createH2cConnector());
    tomcat.addConnectorCustomizers();
    return tomcat;
}

private Connector createH2cConnector() {
    Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
    Http2Protocol upgradeProtocol = new Http2Protocol();
    connector.addUpgradeProtocol(upgradeProtocol);
    connector.setPort(5080);
    return connector;
}

错误 :

java.lang.NullPointerException: null
at org.apache.coyote.Request.doRead(Request.java:551)
at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:336)
4

0 回答 0