Jetty's HTTP/2-Client mit Server-Push-Unterstützung wurde in Jetty 9.3 RC (Link) implementiert. Ich habe jedoch keine diesbezügliche Dokumentation oder Beispielcode gefunden. Könnte jemand einen Beispiel-Code zur Verfügung stellt zum Beispiel der geschoben Ressource von dieser Seite zu erhalten: https://nghttp2.org (öffentlicher Server, die enabled http2 server push hat)Jetty HTTP/2 Client empfängt Server Push-Beispiel
--- UPDATE 1 --- ich versucht habe zu testen this file als sbordet hat sagte. Doch nach dieser Zeile Ausführung
mvn compile exec:java
Ich lief auf diesen Fehler
[INFO] --- exec-maven-plugin:1.4.0:java (default-cli) @ http2client ---
2015-05-05 01:52:47.808:INFO::com.example.Client.main(): Logging initialized @3096ms
[WARNING]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:293)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.concurrent.TimeoutException
at org.eclipse.jetty.util.FuturePromise.get(FuturePromise.java:130)
at com.example.Client.main(Client.java:55)
... 6 more
Hier ist meine pom.xml
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>http2client</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>http2client</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-client</artifactId>
<version>9.3.0.M2</version>
</dependency>
<dependency>
<groupId>org.mortbay.jetty.alpn</groupId>
<artifactId>alpn-boot</artifactId>
<version>8.1.3.v20150130</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.example.Client</mainClass>
</configuration>
</plugin>
</plugins>
</build>
Und hier ist mein Projektverzeichnis
|-- pom.xml
|-- src
| `-- main
| `-- java
| `-- com
| `-- example
| `-- Client.java
`-- target
|-- classes
| `-- com
| `-- example
| |-- Client$1.class
| `-- Client.class
`-- maven-status
`-- maven-compiler-plugin
`-- compile
`-- default-compile
|-- createdFiles.lst
`-- inputFiles.lst
--- UPDATE 2 ---
Changed meinen pom.xml
<build>
Tag folgendermaßen aus: (explizit JDK 8 und fügt -Xbootclasspath zum ALPN-boot.jar von Jetty vorgesehen Punkt). Ich bin mit Java 8 Update 31
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
<argument>-Xbootclasspath/p:/path/to/alpn-boot-8.1.3.v20150130.jar</argument>
<argument>-classpath</argument>
<classpath/>
<argument>com.example.Client</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
Nachdem ich diesen Befehl ausführen:
mvn clean compile exec:exec
ich diesen Fehler bekam, als zu https://webtide.com/ (die Standard-Host in Client.java Datei)
zu verbinden versuchen,[INFO] --- exec-maven-plugin:1.4.0:exec (default-cli) @ http2client ---
2015-05-05 13:19:25.499:INFO::main: Logging initialized @153ms
Exception in thread "main" java.util.concurrent.TimeoutException
at org.eclipse.jetty.util.FuturePromise.get(FuturePromise.java:130)
at com.example.Client.main(Client.java:55)
Und dieser Fehler, wenn sie https://nghttp2.org/
Verbindungs [INFO] --- exec-maven-plugin:1.4.0:exec (default-cli) @ http2client ---
2015-05-05 13:29:12.106:INFO::main: Logging initialized @196ms
Exception in thread "main" java.util.concurrent.TimeoutException
at java.util.concurrent.Phaser.awaitAdvanceInterruptibly(Phaser.java:800)
at com.example.Client.main(Client.java:90)
--- UPDATE 3 ---
einen anderen Ansatz: Wenn ich all Master-Zweig des gesamten Anlegestelle Projektes ziehen, und dann ein Intellij Projekt jetty.project/jetty-http2/http2-client
erstellen dann funktioniert es für öffentlichen Server https://webtide.com und https://nghttp2.org. Aber wenn ich es auf meinem selbstsignierten Prüfzertifikat http2 Server (mit nghttp2 + nginx, in meiner virtuellen Maschine residierte), dann bekomme ich diesen Fehler
2015-05-05 19:05:25.094:INFO::main: Logging initialized @220ms
Exception in thread "main" java.util.concurrent.ExecutionException: java.nio.channels.ClosedChannelException
at org.eclipse.jetty.util.FuturePromise.get(FuturePromise.java:138)
at org.eclipse.jetty.http2.client.Client.main(Client.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.nio.channels.ClosedChannelException
at org.eclipse.jetty.http2.HTTP2Flusher.append(HTTP2Flusher.java:110)
at org.eclipse.jetty.http2.HTTP2Session.frame(HTTP2Session.java:577)
at org.eclipse.jetty.http2.HTTP2Session.frames(HTTP2Session.java:559)
at org.eclipse.jetty.http2.client.HTTP2ClientConnectionFactory$HTTP2ClientConnection.onOpen(HTTP2ClientConnectionFactory.java:121)
Danke, ich habe die Datei aber ausprobiert behalte immer Fehler. Bitte sehen Sie meine aktualisierte Antwort –
Sie müssen die ALPN boot jar in den bootclasspath, wie angegeben [hier] (https://www.eclipse.org/jetty/documentation/current/alpn-chapter.html). Hast du das gemacht ? Sie müssen auch JDK 8 verwenden. Wenn Sie dies getan haben, welchen Server versuchen Sie zu treffen? – sbordet
Ja, ich benutze JDK 8 und jetzt habe ich das ALPN boot jar hinzugefügt, bekomme aber trotzdem einen Fehler. Ich habe versucht, eine Verbindung zu https://webtide.com und https://nghttp2.org herzustellen. Bitte überprüfen Sie mein Update 2. –