11:12:01,161 01-05-2017 [DEBUG] org.eclipse.jetty.server.HttpChannel::commit:760()COMMIT for /rt/serve/handshake on ServerHttpChannelOverHTTP2@7b1897ea{r=1,c=true,a=COMPLETING,uri=https://push2.DOMAIN_NAME.com:8081/rt/serve/handshake}#1200 null HTTP/2.0Server: Jetty(9.3.z-SNAPSHOT)Date: Thu, 05 Jan 2017 16:12:01 GMTAccess-Control-Allow-Origin: http://swinner.www.DOMAIN_NAME.comAccess-Control-Allow-Credentials: trueAccess-Control-Max-Age: 1800Access-Control-Allow-Methods: OPTIONS,HEAD,GET,POST,PUT,DELETE,PATCHAccess-Control-Allow-Headers: content-type,gp-cometd-header,x-csrf-tokenTiming-Allow-Origin: http://swinner.www.DOMAIN_NAME.com
11:12:01,161 01-05-2017 [DEBUG] org.eclipse.jetty.http2.server.HttpChannelOverHTTP2::commit:201()HTTP2 Commit Response #1/61d3f9e3:HTTP/2.0 200 nullServer: Jetty(9.3.z-SNAPSHOT)Date: Thu, 05 Jan 2017 16:12:01 GMTAccess-Control-Allow-Origin: http://swinner.www.DOMAIN_NAME.comAccess-Control-Allow-Credentials: trueAccess-Control-Max-Age: 1800Access-Control-Allow-Methods: OPTIONS,HEAD,GET,POST,PUT,DELETE,PATCHAccess-Control-Allow-Headers: content-type,gp-cometd-header,x-csrf-tokenTiming-Allow-Origin: http://swinner.www.DOMAIN_NAME.com
11:12:01,161 01-05-2017 [DEBUG] org.eclipse.jetty.io.SelectChannelEndPoint::updateKey:230()Key interests updated 1 -> 1 on SelectChannelEndPoint@40ea8e43{/192.168.1.1:51492<->8081,Open,in,out,FI,-,1/30000,SslConnection@67225890}{io=1/1,kio=1,kro=1}
11:12:01,161 01-05-2017 [DEBUG] org.eclipse.jetty.io.ManagedSelector::select:242()Selector loop waiting on select
11:12:01,161 01-05-2017 [DEBUG] org.eclipse.jetty.http2.server.HttpTransportOverHTTP2::commit:178()HTTP2 Response #1:HTTP/2.0 200Server: Jetty(9.3.z-SNAPSHOT)Date: Thu, 05 Jan 2017 16:12:01 GMTAccess-Control-Allow-Origin: http://swinner.www.DOMAIN_NAME.comAccess-Control-Allow-Credentials: trueAccess-Control-Max-Age: 1800Access-Control-Allow-Methods: OPTIONS,HEAD,GET,POST,PUT,DELETE,PATCHAccess-Control-Allow-Headers: content-type,gp-cometd-header,x-csrf-tokenTiming-Allow-Origin: http://swinner.www.DOMAIN_NAME.com
11:12:01,161 01-05-2017 [DEBUG] org.eclipse.jetty.http2.HTTP2Session::frame:661()Sending HeadersFrame@7e749d29#1{end=true}
11:12:01,162 01-05-2017 [DEBUG] org.eclipse.jetty.http2.HTTP2Flusher::append:100()Appended HeadersFrame@7e749d29#1{end=true}, frames=1
11:12:01,162 01-05-2017 [DEBUG] org.eclipse.jetty.http2.HTTP2Flusher::process:129()Flushing HTTP2ServerSession@61d3f9e3{l:/10.2.0.195:8081 <-> r:/192.168.1.1:51492,queueSize=1,sendWindow=15728640,recvWindow=65535,streams=1,NOT_CLOSED}
11:12:01,162 01-05-2017 [DEBUG] org.eclipse.jetty.http2.HTTP2Flusher::process:209()Gathered for write HeadersFrame@7e749d29#1{end=true}
11:12:01,162 01-05-2017 [DEBUG] org.eclipse.jetty.http2.hpack.HpackEncoder::encode:145()CtxTbl[3c1f54d7] encoding
11:12:01,162 01-05-2017 [DEBUG] org.eclipse.jetty.http2.hpack.HpackEncoder::encode:343()encode IdxFieldS1:':status: 200' to '88'
11:12:01,162 01-05-2017 [DEBUG] org.eclipse.jetty.http2.HTTP2Session::generate:1131()Failure generating frame HeadersFrame@7e749d29#1{end=true}
java.lang.ArrayIndexOutOfBoundsException: 1 at org.eclipse.jetty.http.PreEncodedHttpField.putTo(PreEncodedHttpField.java:119) ~[rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.http2.hpack.HpackEncoder.encode(HpackEncoder.java:289) ~[rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.http2.hpack.HpackEncoder.encode(HpackEncoder.java:179) ~[rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.http2.generator.HeadersGenerator.generateHeaders(HeadersGenerator.java:72) ~[rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.http2.generator.HeadersGenerator.generate(HeadersGenerator.java:56) ~[rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.http2.generator.Generator.control(Generator.java:80) ~[rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.http2.HTTP2Session$ControlEntry.generate(HTTP2Session.java:1122) [rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.http2.HTTP2Flusher.process(HTTP2Flusher.java:232) [rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.util.IteratingCallback.processing(IteratingCallback.java:241) [rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:224) [rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.http2.HTTP2Session.frame(HTTP2Session.java:668) [rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.http2.HTTP2Session.frames(HTTP2Session.java:640) [rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.http2.HTTP2Stream.headers(HTTP2Stream.java:87) [rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.http2.server.HttpTransportOverHTTP2.commit(HttpTransportOverHTTP2.java:184) [rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.http2.server.HttpTransportOverHTTP2.send(HttpTransportOverHTTP2.java:116) [rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.server.HttpChannel.sendResponse(HttpChannel.java:725) [rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.server.HttpChannel.write(HttpChannel.java:781) [rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:235) [rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:219) [rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.server.HttpOutput.close(HttpOutput.java:269) [rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.server.Response.closeOutput(Response.java:970) [rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:454) [rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:267) [rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671) [rt.runnable.ej.build.37.jar:?] at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589) [rt.runnable.ej.build.37.jar:?] at java.lang.Thread.run(Thread.java:745) [?:1.8.0_101]11:12:01,163 01-05-2017 [DEBUG] org.eclipse.jetty.http2.HTTP2Flusher::onCompleteFailure:279()Failing, active/queued=1/0
11:12:01,163 01-05-2017 [DEBUG] org.eclipse.jetty.http2.HTTP2Session::removeStream:762()Removed remote HTTP2Stream@7f1a0fc6#1{sendWindow=6291456,recvWindow=65535,reset=false,CLOSED}
11:12:01,163 01-05-2017 [DEBUG] org.eclipse.jetty.http2.server.HttpTransportOverHTTP2::failed:298()HTTP2 Response #1 failed to flush
java.lang.ArrayIndexOutOfBoundsException: 1 at org.eclipse.jetty.http.PreEncodedHttpField.putTo(PreEncodedHttpField.java:119) ~[rt.runnable.ej.build.37.jar:?]
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
java -d64 -server -XX:+UseG1GC -Xbootclasspath/p:/opt/alpn_jars/alpn-boot-8.1.9.v20160720.jar -Djava.net.preferIPv4Stack=true -jar rt_cometd_embedded_jetty.jar push1test
Hi,
On Thu, Jan 5, 2017 at 5:41 PM, steven winner <steven...@gmail.com> wrote:
> 11:12:01,162 01-05-2017 [DEBUG]
> org.eclipse.jetty.http2.HTTP2Session::generate:1131()
> Failure generating frame HeadersFrame@7e749d29#1{end=true}
>
> java.lang.ArrayIndexOutOfBoundsException: 1
> at
> org.eclipse.jetty.http.PreEncodedHttpField.putTo(PreEncodedHttpField.java:119)
This error means that you don't have the classpath setup right.
PreEncodedHttpField looks up classes via the ServiceLoader mechanism,
and looks like the http2-hpack jar is not in the server classpath.
Once you fix that, you should be good with HTTP/2.
Your code looks okay at a first view.
One thing though. On port 8080 you setup a HTTP/1.1 and HTTP/2 clear text.
Be aware that only non-browser clients will be able to talk HTTP/2 to
port 8080 by directly issuing a HTTP/2 preface.
Your call whether you want to keep it or not.
HTTP2CServerConnectionFactory vs HTTP2ServerConnectionFactory
Also, is there anything worth noting/mentioning as far as choosing Jetty 9.3 or 9.4 ?
Thanks again for the quick feedback. Keep up the great work
11:12:01,162 01-05-2017 [DEBUG] org.eclipse.jetty.http2.hpack.HpackEncoder::encode:145()
CtxTbl[3c1f54d7] encoding
11:12:01,162 01-05-2017 [DEBUG] org.eclipse.jetty.http2.hpack.HpackEncoder::encode:343()
encode IdxFieldS1:':status: 200' to '88'
Hi,
If you are adding all the dependencies in an uber-jar, make sure that
the http2-hpack jar is there.
If you change the package names via shading, you have to make sure
that files looked up with ServiceLoader are transformed as well.
Having a clear-text port may be useful for debugging, since you don't
have TLS in the mix.
Also, you may compare the performance between the two.
Note that I don't particularly recommend to perform TLS offloading in
Java, too slow and memory hungry.
Best solution would be to offload at HAProxy and then forward the
clear-text traffic to Jetty.
Having said that, having 2 connectors is really your choice, as one
would be enough.
Jetty 9.3.x vs Jetty 9.4.x. If you need super-stability, 9.3.x is more mature.
Jetty 9.4.x has been just released, and we found 9.4.0 a bit rough -
9.4.1 will come out soon.
Jetty 9.4.x is much better with respect to HTTP/2 and it is of course
where we will concentrate in the next future.
So if 9.4.x works for you, stick with it, but have a process to be
able to upgrade it as we make fixes and improvements (you need to have
this for 9.3.x too, but we expect the releases on the 9.3.x series to
be much less frequent now that 9.4.x is out).
> I was going about adding that http2-hpack jar and noticed no difference, but
> then looking at the logs (the original example included), it looks like that
> jar has to be included since it's logging debug statements right before that
> ArrayIndexOutOfBoundsException. So I'm not so sure if that is where the
> issue is (unless I'm missing something)
Are you shading it ?
Is this copying also the files under META-INF/services ?
For example: https://github.com/eclipse/jetty.project/tree/jetty-9.4.0.v20161208/jetty-http2/http2-hpack/src/main/resources/META-INF
<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-server</artifactId>
<version>${jetty-version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-client</artifactId>
<version>${jetty-version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-common</artifactId>
<version>${jetty-version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-hpack</artifactId>
<version>${jetty-version}</version>
</dependency>
<dependency>
<groupId>org.mortbay.jetty.alpn</groupId>
<artifactId>alpn-boot</artifactId>
<version>8.1.9.v20160720</version>
</dependency>
jar xf uberjar.jar
prompt$ ll ./META-INF/services/total 52Kdrwxr-xr-x 2 root root 4.0K Jan 9 12:03 ./drwxr-xr-x 6 root root 4.0K Jan 9 13:49 ../-rw-r--r-- 1 root root 50 Jan 9 12:03 com.fasterxml.jackson.core.JsonFactory-rw-r--r-- 1 root root 44 Jan 9 12:03 com.fasterxml.jackson.core.ObjectCodec-rw-r--r-- 1 root root 61 Jan 9 12:03 java.sql.Driver-rw-r--r-- 1 root root 855 Jan 9 12:03 javax.annotation.processing.Processor-rw-r--r-- 1 root root 36 Jan 9 12:03 javax.cache.spi.CachingProvider-rw-r--r-- 1 root root 84 Jan 9 12:03 javax.servlet.ServletContainerInitializer-rw-r--r-- 1 root root 63 Jan 9 12:03 javax.websocket.ContainerProvider-rw-r--r-- 1 root root 70 Jan 9 12:03 javax.websocket.server.ServerEndpointConfig$Configurator-rw-r--r-- 1 root root 43 Jan 9 12:03 org.eclipse.jetty.http.HttpFieldPreEncoder-rw-r--r-- 1 root root 389 Jan 9 12:03 org.eclipse.jetty.websocket.api.extensions.Extension-rw-r--r-- 1 root root 57 Jan 9 12:03 org.eclipse.jetty.websocket.servlet.WebSocketServletFactory
prompt$ ll org/eclipse/jetty/http2/hpack/ total 104Kdrwxr-xr-x 2 root root 4.0K Jan 9 12:03 ./drwxr-xr-x 9 root root 4.0K Jan 9 12:03 ../-rw-r--r-- 1 root root 1.2K Jan 9 12:03 AuthorityHttpField.class-rw-r--r-- 1 root root 802 Jan 9 12:03 HpackContext$1.class-rw-r--r-- 1 root root 11K Jan 9 12:03 HpackContext.class-rw-r--r-- 1 root root 4.0K Jan 9 12:03 HpackContext$DynamicTable.class-rw-r--r-- 1 root root 1.7K Jan 9 12:03 HpackContext$Entry.class-rw-r--r-- 1 root root 1.8K Jan 9 12:03 HpackContext$StaticEntry.class-rw-r--r-- 1 root root 811 Jan 9 12:03 HpackDecoder$1.class-rw-r--r-- 1 root root 7.7K Jan 9 12:03 HpackDecoder.class-rw-r--r-- 1 root root 13K Jan 9 12:03 HpackEncoder.class-rw-r--r-- 1 root root 2.6K Jan 9 12:03 HpackFieldPreEncoder.class-rw-r--r-- 1 root root 9.2K Jan 9 12:03 Huffman.class-rw-r--r-- 1 root root 1012 Jan 9 12:03 MetaDataBuilder$1.class-rw-r--r-- 1 root root 4.9K Jan 9 12:03 MetaDataBuilder.class-rw-r--r-- 1 root root 1.9K Jan 9 12:03 NBitInteger.class-rw-r--r-- 1 root root 1.8K Jan 9 12:03 StaticTableHttpField.class
prompt$ cat org.eclipse.jetty.http.HttpFieldPreEncoderorg.eclipse.jetty.http.Http1FieldPreEncoder
org.eclipse.jetty.http2.hpack.HpackFieldPreEncoder
<dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-http</artifactId>
<version>${jetty-version}</version></dependency>
Exception in thread "main" java.lang.ExceptionInInitializerError at org.eclipse.jetty.http.MimeTypes$Type.<init>(MimeTypes.java:95) at org.eclipse.jetty.http.MimeTypes$Type.<clinit>(MimeTypes.java:51) at org.eclipse.jetty.http.MimeTypes.<clinit>(MimeTypes.java:188) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:772) at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131) at org.eclipse.jetty.server.Server.start(Server.java:452) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) at org.eclipse.jetty.server.Server.doStart(Server.java:419) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at com.gp.rt.RtServerMain.run(RtServerMain.java:127) at com.gp.rt.RtServerMain.main(RtServerMain.java:60)Caused by: java.lang.ArrayIndexOutOfBoundsException: 1 at org.eclipse.jetty.http.PreEncodedHttpField.<clinit>(PreEncodedHttpField.java:71) ... 14 more
public boolean canHandshake(BayeuxServer server, ServerSession session, ServerMessage message)
String scheme = server.getContext().getURL().split(":")[0];
String transport = server.getCurrentTransport().getName();
Currently, there is no way, unless you want to resort to
Jetty-specific APIs, but I won't recommend it.
Can you please file an issue ? We may export this information in BayeuxContext.