gpt4 book ai didi

java - ALPN 回调下降 : SPDY and HTTP/2 are disabled. alpn-boot 是否在引导类路径上?

转载 作者:搜寻专家 更新时间:2023-11-01 03:15:27 27 4
gpt4 key购买 nike

尝试让 Apple 推送通知与我的 Spring Boot 项目一起工作。

我正在使用此 apns-http2 发送推送通知。从他们的 GitGub 页面:

Note: Ensure that you have Jetty's ALPN JAR (OkHttp requires it) in your boot classpath. See here for more information. This is required until Java 9 is released, as Java 8 does not have native support for HTTP/2.

所以我添加了vm选项

Xbootclasspath/p:/Users/sarath/.m2/repository/org/mortbay/jetty/alpn/alpn-boot/8.1.9.v20160720//alpn-boot-8.1.9.v20160720.jar

在 Intellij 中运行配置,一切正常。我收到推送通知。

但是当我将 war 部署到 tomcat 并尝试发送推送通知时,出现错误:

20-Apr-2019 13:08:33.400 INFO [OkHttp https://api.development.push.apple.com/3/device/A704797F6E1E284FB081630184A26755B59593715E1CD543483C2136CE24D4FD] okhttp3.internal.Platform$JdkWithJettyBootPlatform.getSelectedProtocol ALPN callback dropped: SPDY and HTTP/2 are disabled. Is alpn-boot on the boot class path?
20-Apr-2019 13:08:34.935 INFO [OkHttp https://api.development.push.apple.com/3/device/A704797F6E1E284FB081630184A26755B59593715E1CD543483C2136CE24D4FD] okhttp3.internal.Platform$JdkWithJettyBootPlatform.getSelectedProtocol ALPN callback dropped: SPDY and HTTP/2 are disabled. Is alpn-boot on the boot class path?
20-Apr-2019 13:08:36.588 INFO [OkHttp https://api.development.push.apple.com/3/device/A704797F6E1E284FB081630184A26755B59593715E1CD543483C2136CE24D4FD] okhttp3.internal.Platform$JdkWithJettyBootPlatform.getSelectedProtocol ALPN callback dropped: SPDY and HTTP/2 are disabled. Is alpn-boot on the boot class path?
20-Apr-2019 13:08:38.109 INFO [OkHttp https://api.development.push.apple.com/3/device/A704797F6E1E284FB081630184A26755B59593715E1CD543483C2136CE24D4FD] okhttp3.internal.Platform$JdkWithJettyBootPlatform.getSelectedProtocol ALPN callback dropped: SPDY and HTTP/2 are disabled. Is alpn-boot on the boot class path?
failure: NotificationResponse{error=null, httpStatusCode=-1, responseBody='null', cause=java.io.IOException: unexpected end of stream on okhttp3.Address@d60ab6f0}

我不确定如何在引导类路径上设置 alpn-boot。我尝试执行

java -Xbootclasspath/p:/Users/sarath/.m2/repository/org/mortbay/jetty/alpn/alpn-boot/8.1.9.v20160720/alpn-boot-8.1.9.v20160720.jar

从命令提示符。但这只显示了一些 Java 帮助命令。不知道这个jar是不是真的加入了boot类路径。

我也试过使用 maven-surefire-plugin 就像它说的 here .但仍然出现同样的错误。

这是我的 pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.cinch</groupId>
<artifactId>gch</artifactId>
<version>2.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>com.cinch.gch</groupId>
<artifactId>apn</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<name>apn</name>
<description>Contains push notification services</description>

<properties>
<java.version>1.8</java.version>
<alpn-boot-version>8.1.9.v20160720</alpn-boot-version>
</properties>

<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>

<dependency>
<groupId>com.cinch.gch</groupId>
<artifactId>core</artifactId>
<version>1.0.0</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>

<dependency>
<groupId>com.cinch</groupId>
<artifactId>gch-cache</artifactId>
</dependency>

<dependency>
<groupId>org.mortbay.jetty.alpn</groupId>
<artifactId>alpn-boot</artifactId>
<version>${alpn-boot-version}</version>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>com.clevertap.apns</groupId>
<artifactId>apns-http2</artifactId>
<version>1.0.3</version>
</dependency>

</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>
-Xbootclasspath/p:/Users/sarath/.m2/repository/org/mortbay/jetty/alpn/alpn-boot/${alpn-boot-version}/alpn-boot-${alpn-boot-version}.jar
</argLine>
</configuration>
</plugin>

</plugins>
<finalName>gch-apn</finalName>
</build>

</project>

我尝试了很多其他的东西,但似乎没有任何效果。

最佳答案

正如 AlexanderPavlov 在评论中指出的那样。

If it must be on bootpath then you have to put it somewhere and add -Xbootclasspath option to java command-line arguments in catalina.bat/.sh

我在 Tomcat_Home/bin/中创建了一个名为 setenv.sh 的文件

setenv.sh

export CATALINA_OPTS="-Xbootclasspath/p:/Users/sarath/.m2/repository/org/mortbay/jetty/alpn/alpn-boot/8.1.9.v20160720//alpn-boot-8.1.9.v20160720.jar"

catalina.bat/.sh 将自动读取 setenv.sh(如果存在)。

关于java - ALPN 回调下降 : SPDY and HTTP/2 are disabled. alpn-boot 是否在引导类路径上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55771688/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com