CometD 3.1.0 Released

89 views
Skip to first unread message

Simone Bordet

unread,
Jan 4, 2017, 12:13:31 PM1/4/17
to cometd-users, cometd-dev
Hi,

CometD 3.1.0 has been released.

https://webtide.com/cometd-3-1-0-released/

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.

steven winner

unread,
Jan 5, 2017, 9:33:39 AM1/5/17
to cometd-users, comet...@googlegroups.com, sbo...@webtide.com
Are there any examples available for setting up embedded Jetty and HTTP2/ALPN ?  Gave it a shot yesterday, but couldn't get it working.  Going to give it another shot again today.

Awesome release though!  Everything seems good so far from my tests.

Simone Bordet

unread,
Jan 5, 2017, 9:36:11 AM1/5/17
to cometd-users
Hi,

On Thu, Jan 5, 2017 at 3:33 PM, steven winner <steven...@gmail.com> wrote:
> Are there any examples available for setting up embedded Jetty and
> HTTP2/ALPN ? Gave it a shot yesterday, but couldn't get it working. Going
> to give it another shot again today.

What problems did you have ?

> Awesome release though! Everything seems good so far from my tests.

Thanks for the feedback !

steven winner

unread,
Jan 5, 2017, 11:41:07 AM1/5/17
to cometd-users, sbo...@webtide.com
Simone,

I am attaching the code I'm using to setup the jetty server, CometD servlets, and my application's servlets, along with the jetty/alpn debug log, but I think some of the relevant bits of the log may be this (around line 1500):

*replaced ip and domain name for obv reasons
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}#1
200 null HTTP/2.0
Server: Jetty(9.3.z-SNAPSHOT)
Date: Thu, 05 Jan 2017 16:12:01 GMT
Access-Control-Allow-Origin: http://swinner.www.DOMAIN_NAME.com
Access-Control-Allow-Credentials: true
Access-Control-Max-Age: 1800
Access-Control-Allow-Methods: OPTIONS,HEAD,GET,POST,PUT,DELETE,PATCH
Access-Control-Allow-Headers: content-type,gp-cometd-header,x-csrf-token

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 null
Server: Jetty(9.3.z-SNAPSHOT)
Date: Thu, 05 Jan 2017 16:12:01 GMT
Access-Control-Allow-Origin: http://swinner.www.DOMAIN_NAME.com
Access-Control-Allow-Credentials: true
Access-Control-Max-Age: 1800
Access-Control-Allow-Methods: OPTIONS,HEAD,GET,POST,PUT,DELETE,PATCH
Access-Control-Allow-Headers: content-type,gp-cometd-header,x-csrf-token

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 200
Server: Jetty(9.3.z-SNAPSHOT)
Date: Thu, 05 Jan 2017 16:12:01 GMT
Access-Control-Allow-Origin: http://swinner.www.DOMAIN_NAME.com
Access-Control-Allow-Credentials: true
Access-Control-Max-Age: 1800
Access-Control-Allow-Methods: OPTIONS,HEAD,GET,POST,PUT,DELETE,PATCH
Access-Control-Allow-Headers: content-type,gp-cometd-header,x-csrf-token

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:?]



Using jetty 9.3.15.v20161220 and CometD 3.1.0 (obv)

Java details:

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)


Running the self contained jar like so (I supposedly have the "correct" version of the alpn boot jar according to the jetty site, but idk for sure)

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


From the client/JS side, I've updated the cometd js library to the 3.1.0 (jquery binding), and have disabled websockets, since I'm testing http2.  In the chrome console, all the secure/https attempts fail with net::ERR_CONNECTION_CLOSED before finally connecting to normal http 1.1 long polling

I've tried with jetty 9.4, but seemed to be the same.

It's not a big deal, since websockets are still the best way to go for our app IMO, but would still love to get HTTP2 working to give it a shot.

Thanks!


jetty_http2_server.java
jetty_debug.log
alpn_debug.log

Simone Bordet

unread,
Jan 5, 2017, 12:46:41 PM1/5/17
to cometd-users, Bordet, Simone
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.

steven winner

unread,
Jan 5, 2017, 12:58:05 PM1/5/17
to cometd-users, sbo...@webtide.com
Simone,


On Thursday, January 5, 2017 at 12:46:41 PM UTC-5, Simone Bordet wrote:
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.

Since this is a runnable jar that contains all dependencies, would adding a maven dependency work for that?  I've checked what the classpath was, and it just says the jar.
 

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.

Ok, cool, that's good to know.  All I'm aiming for is one port for secure/https, and one port for regular http as a fallback.  The 8080/80801 is just for my test builds (production uses 80/443). 

Since I basically hacked that together from examples I found from various locations, what would you recommend for the connectors.  I'm not really sure what the best way to set that up is, or why there are two HTTP2 connectors

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

steven winner

unread,
Jan 5, 2017, 3:51:02 PM1/5/17
to cometd-users, sbo...@webtide.com
Simone,

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)

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'


Simone Bordet

unread,
Jan 6, 2017, 7:07:44 AM1/6/17
to cometd-users, Bordet, Simone
Hi,

On Thu, Jan 5, 2017 at 6:58 PM, steven winner <steven...@gmail.com> wrote:
> Since this is a runnable jar that contains all dependencies, would adding a
> maven dependency work for that? I've checked what the classpath was, and it
> just says the jar.

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.

> Since I basically hacked that together from examples I found from various
> locations, what would you recommend for the connectors. I'm not really sure
> what the best way to set that up is, or why there are two HTTP2 connectors
>
> HTTP2CServerConnectionFactory vs HTTP2ServerConnectionFactory
>
> Also, is there anything worth noting/mentioning as far as choosing Jetty 9.3
> or 9.4 ?

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).

Simone Bordet

unread,
Jan 6, 2017, 7:08:38 AM1/6/17
to cometd-users, Bordet, Simone
Hi,

On Thu, Jan 5, 2017 at 9:51 PM, steven winner <steven...@gmail.com> wrote:
> Simone,
>
> 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 ?

steven winner

unread,
Jan 6, 2017, 9:29:58 AM1/6/17
to cometd-users, sbo...@webtide.com


On Friday, January 6, 2017 at 7:07:44 AM UTC-5, Simone Bordet wrote:
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. 

I've got that jar in there (tried two different ways, by maven dependency, and adding to the manifest).

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). 
 
Ok, cool... That's pretty much what I was figuring.  I read the article on webtide about 9.4 and TLS
and proxying through HAProxy/nginx.  Pretty interesting and that's something I might play around with
when I've got some time.

steven winner

unread,
Jan 6, 2017, 9:32:06 AM1/6/17
to cometd-users, sbo...@webtide.com
Simone,

> 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 ?

Not shading it.  Compiling/creating the runnable jar via the maven assembly plugin using the jar-with-dependencies option.

Simone Bordet

unread,
Jan 6, 2017, 10:09:32 AM1/6/17
to steven winner, cometd-users, Bordet, Simone
Hi,

On Fri, Jan 6, 2017 at 3:32 PM, steven winner <steven...@gmail.com> wrote:
> Simone,
>
>> > 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 ?
>
>
> Not shading it. Compiling/creating the runnable jar via the maven assembly
> plugin using the jar-with-dependencies option.

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

steve winner

unread,
Jan 6, 2017, 10:26:31 AM1/6/17
to Simone Bordet, cometd-users
Simone,
That’s a good question.  How would you go about determining that?  Would that be listed in the jar’s manifest file?

Simone Bordet

unread,
Jan 6, 2017, 10:31:06 AM1/6/17
to steve winner, Simone Bordet, cometd-users
Hi,

On Fri, Jan 6, 2017 at 4:26 PM, steve winner <steven...@gmail.com> wrote:
> Simone,
>
> 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
>
>
> That’s a good question. How would you go about determining that? Would
> that be listed in the jar’s manifest file?

Nope, it's not the manifest file.
It's an additional file under META-INF/services.

Crack open your uber jar and see if it's there.

steve winner

unread,
Jan 6, 2017, 12:14:46 PM1/6/17
to Simone Bordet, cometd-users
Simone,

>> 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
>>
>>
>> That’s a good question. How would you go about determining that? Would
>> that be listed in the jar’s manifest file?
>
> Nope, it's not the manifest file.
> It's an additional file under META-INF/services.
>
> Crack open your uber jar and see if it's there.


I’ll check out the contents of the jar and report back. But in the meantime, let’s assume it’s not being included for some reason, and as I mentioned, I’m currently building the jar via the maven assembly plugin, (but I understand that’s only one way to do it), is it simple to add that dependency/resource to the jar?

If that’s beyond the scope of this group/thread, I understand, but I bet you know :-P

Thanks again for your help

Steve

Simone Bordet

unread,
Jan 6, 2017, 12:59:58 PM1/6/17
to steve winner, Simone Bordet, cometd-users
Hi,

On Fri, Jan 6, 2017 at 6:14 PM, steve winner <steven...@gmail.com> wrote:
> I’ll check out the contents of the jar and report back. But in the meantime, let’s assume it’s not being included for some reason, and as I mentioned, I’m currently building the jar via the maven assembly plugin, (but I understand that’s only one way to do it), is it simple to add that dependency/resource to the jar?
>
> If that’s beyond the scope of this group/thread, I understand, but I bet you know :-P

First thing I thought was: why are you using the assembly plugin and
not the shade plugin to make the uber jar ?
I know the shade plugin "knows" about service files.

steve winner

unread,
Jan 6, 2017, 1:04:49 PM1/6/17
to Simone Bordet, cometd-users
Simone,

> First thing I thought was: why are you using the assembly plugin and
> not the shade plugin to make the uber jar ?
> I know the shade plugin "knows" about service files.

apparently there are multiple ways to go about creating those uber/runnable jars via maven plugins, and I only used the assembly plugin because I found a simple example and it worked, so I went with that. However I saw the shade plugin recommended many times while I was researching it, so thanks for that, because it seems like that might be the better way to go, so I’ll give that a try and report back.

Thanks again!

steven winner

unread,
Jan 9, 2017, 12:15:45 PM1/9/17
to cometd-users, sbo...@webtide.com
Simone,

So I finally had time to give the mave-shade-plugin a go, and I like it better than the assembly-plugin, it's still giving me the same exact error/warning.  I have these dependencies in my pom for http2, so I'm not sure why it's not working:

<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>


I'll play around some more with it, but since it's not really a huge deal (more of an annoyance and wanting to test it out), I'm not going to worry about it too much.  

I do think however it would be useful/beneficial to have an example/test either in the distribution tar or in the documentation on setting up an embedded jetty server with http2 (I bet you've got something laying around).

Thanks again for the assistance.

Simone Bordet

unread,
Jan 9, 2017, 1:29:17 PM1/9/17
to cometd-users, Bordet, Simone
Hi,

On Mon, Jan 9, 2017 at 6:15 PM, steven winner <steven...@gmail.com> wrote:
> Simone,
>
> So I finally had time to give the mave-shade-plugin a go, and I like it
> better than the assembly-plugin, it's still giving me the same exact
> error/warning.

If you open the uber jar, is the file there ?

steven winner

unread,
Jan 9, 2017, 1:58:14 PM1/9/17
to cometd-users, sbo...@webtide.com
So I unpacked the jar 

jar xf uberjar.jar

and when I look where I think it should be (could be wrong), I see the http version, but not http2 version:

prompt$ ll ./META-INF/services/
total 52K
drwxr-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

this is what I see when I look at the compiled classes:

prompt$ ll org/eclipse/jetty/http2/hpack/ 
total 104K
drwxr-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

Does that resource need to be included explicitly?  If so, how do you specify resources from a dependency to be included? (I know how to add local resources and I'm doing so for my .properties files for configuration)

Thanks! 

steven winner

unread,
Jan 9, 2017, 2:05:16 PM1/9/17
to cometd-users, sbo...@webtide.com
Just noticed that the file name is correct, but the value isn't right:

prompt$ cat org.eclipse.jetty.http.HttpFieldPreEncoder
org.eclipse.jetty.http.Http1FieldPreEncoder

when I think it's supposed to be:
org.eclipse.jetty.http2.hpack.HpackFieldPreEncoder

is there an obvious reason for this? conflicting dependancies? 

steven winner

unread,
Jan 9, 2017, 2:43:38 PM1/9/17
to cometd-users, sbo...@webtide.com
Simone,

So I think it's most likely an issue with my dependencies either conflicting or not setup/ordered correctly.  For the jetty-http dependency, I tried both removing and moving it after the http2 dependencies:

<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-http</artifactId>
    <version>${jetty-version}</version>
</dependency>

and the server didn't start when it was removed and if I moved it after the http2 dependencies, I got that same Exception, but in the main thread, not buried in the debug logs:

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

I'm attaching my pom.xml because I'd bet the problem is there

Thanks again
pom.xml

Simone Bordet

unread,
Jan 9, 2017, 3:15:58 PM1/9/17
to cometd-users, Bordet, Simone
Hi,

On Mon, Jan 9, 2017 at 8:05 PM, steven winner <steven...@gmail.com> wrote:
> Just noticed that the file name is correct, but the value isn't right:
>
> prompt$ cat org.eclipse.jetty.http.HttpFieldPreEncoder
> org.eclipse.jetty.http.Http1FieldPreEncoder
>
> when I think it's supposed to be:
>
> org.eclipse.jetty.http2.hpack.HpackFieldPreEncoder
>
>
> is there an obvious reason for this? conflicting dependancies?

Both values should be there.

Please have a look at the service file transformer:
http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#ServicesResourceTransformer

steven winner

unread,
Jan 9, 2017, 3:41:39 PM1/9/17
to cometd-users, sbo...@webtide.com
Simone,

That's the part that was missing... Thanks for sticking in there with me.  I've got it working now :)

That was a hell of an adventure, but it's something I've been trying to play around with now for a while (like since jetty 9.3 dropped).  So it's nice to have that one solved and definitely learned a bit along the way.


Keep up the great work!
-Steve

steven winner

unread,
Jan 11, 2017, 7:23:22 PM1/11/17
to cometd-users, sbo...@webtide.com
One last question regarding http2... Is there anyway to determine the protocol being used from the canHandshake method?:

public boolean canHandshake(BayeuxServer server, ServerSession session, ServerMessage message)

Until now, I was tracking the connection stats from the server context url like so:

String scheme = server.getContext().getURL().split(":")[0];

and it would be http, https, ws or wss and together with:

String transport = server.getCurrentTransport().getName();

you could keep track of the transport and secure/regular connection, but for http2, it will be https for long-polling if they are using http2 or 1.1  

Is there a way to determine the protocol being used?  Not a big deal, but would be nice to be able to keep stats on those connections

Simone Bordet

unread,
Jan 12, 2017, 5:20:13 PM1/12/17
to cometd-users, Bordet, Simone
Hi,

On Thu, Jan 12, 2017 at 1:23 AM, steven winner <steven...@gmail.com> wrote:
> One last question regarding http2... Is there anyway to determine the
> protocol being used from the canHandshake method?:
>
> public boolean canHandshake(BayeuxServer server, ServerSession session,
> ServerMessage message)
>
>
> Until now, I was tracking the connection stats from the server context url
> like so:
>
> String scheme = server.getContext().getURL().split(":")[0];
>
>
> and it would be http, https, ws or wss and together with:
>
> String transport = server.getCurrentTransport().getName();
>
>
> you could keep track of the transport and secure/regular connection, but for
> http2, it will be https for long-polling if they are using http2 or 1.1
>
> Is there a way to determine the protocol being used? Not a big deal, but
> would be nice to be able to keep stats on those connections

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.

steven winner

unread,
Jan 13, 2017, 5:04:05 PM1/13/17
to cometd-users, sbo...@webtide.com
Simone,
 
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.

Reply all
Reply to author
Forward
0 new messages