Sending Http requests over Spdy

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Sending Http requests over Spdy

Nicholas Lun
This post was updated on .
Hi all,

I am aware that there is a SPDY client that talks pure SPDY (not http over spdy). I was wondering if I set up two Jetty instances with SPDY connectors, can I use Jetty's http client to send http requests over spdy from one to the other?

edit: I am using Jetty 9.0.6

Thanks!
Nick
Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] Sending Http requests over Spdy

Simone Bordet-2
Hi,

On Wed, Oct 30, 2013 at 1:28 AM, Nicholas Lun <[hidden email]> wrote:
> Hi all,
>
> I am aware that there is a SPDY client that talks pure SPDY (not http over
> spdy). I was wondering if I set up two Jetty instances with SPDY connectors,
> can I use Jetty's http client to send http requests over spdy from one to
> the other?

You can in Jetty 9.1, see
http://webtide.intalio.com/2013/10/pluggable-transports-for-jetty-9-1s-httpclient/.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.
_______________________________________________
jetty-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] Sending Http requests over Spdy

Nicholas Lun
Thanks! Wondering why I couldn't find this earlier, looks like I will have to upgrade to 9.1
Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] Sending Http requests over Spdy

Nicholas Lun
In reply to this post by Simone Bordet-2
I tried commenting on the blog but it's giving me a captcha error.

Just trying out Jetty 9.1 RC0 and the example in the blog. HttpClient's constructor takes an object of type HttpClientTransport, not of SPDYClient. Am I missing something here?
Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] Sending Http requests over Spdy

Simone Bordet-2
Hi,

On Wed, Oct 30, 2013 at 10:07 PM, Nicholas Lun <[hidden email]> wrote:
> I tried commenting on the blog but it's giving me a captcha error.
>
> Just trying out Jetty 9.1 RC0 and the example in the blog. HttpClient's
> constructor takes an object of type HttpClientTransport, not of SPDYClient.
> Am I missing something here?

No the code is wrong, my bad.
It's fixed now.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.
_______________________________________________
jetty-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] Sending Http requests over Spdy

Nicholas Lun
Thanks Simone!

I got it working and sending requests to an http-spdy connector. Out of curiosity, is there way to get it to send requests to an npn connector?
Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] Sending Http requests over Spdy

Simone Bordet-2
Hi,

On Mon, Nov 4, 2013 at 7:44 PM, Nicholas Lun <[hidden email]> wrote:
> Thanks Simone!
>
> I got it working and sending requests to an http-spdy connector. Out of
> curiosity, is there way to get it to send requests to an npn connector?

What do you mean ?
There is no such a thing as an NPN connector.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.
_______________________________________________
jetty-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] Sending Http requests over Spdy

Nicholas Lun
This post was updated on .
Apologies, I meant the following.

If I initialize my connector like so it works.

HTTPSPDYServerConnectionFactory spdy3 = new HTTPSPDYServerConnectionFactory(SPDY.V3, new HttpConfiguration(), new PushStrategy.None());
ServerConnector spdyClientConnector = new ServerConnector(_jetty, spdy3);

However, if I set up a spdy connector to have fallbacks like in this example: http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/examples/embedded/src/main/java/org/eclipse/jetty/embedded/SpdyConnector.java

I get a "400: Bad Message" error when I send a request to it via httpclient over spdy. The only difference with on the client side is that the httpclient and the spdy client is passed a sslContextFactory as a parameter.

Edit: here is some output from the logs

 WARN 2013-11-04 14:59:53,069 [org.eclipse.jetty.http.HttpParser qtp1858166774-30] badMessage: 400 for HttpChannelOverHttp@f764569{r=0,a=IDLE,uri=-}
DEBUG 2013-11-04 14:59:53,069 [org.eclipse.jetty.http.HttpParser qtp1858166774-30]
org.eclipse.jetty.http.HttpParser$BadMessage
        at org.eclipse.jetty.http.HttpParser.quickStart(HttpParser.java:380)
        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1142)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:211)
        at org.eclipse.jetty.io.AbstractConnection$1.run(AbstractConnection.java:505)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:601)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:532)
        at java.lang.Thread.run(Thread.java:724)
DEBUG 2013-11-04 14:59:53,070 [org.eclipse.jetty.http.HttpParser qtp1858166774-30] START --> CLOSED
DEBUG 2013-11-04 14:59:53,070 [org.eclipse.jetty.client.HttpSender HttpClient@952933102-43] Request content HttpRequest[GET /altProcRemote/runload HTTP/1.1]@2c53cfe3
HeapByteBuffer@1b0324a3[p=0,l=100,c=100,r=100]={<<<?????????????????...???????????????>>>}



Hi,

On Mon, Nov 4, 2013 at 7:44 PM, Nicholas Lun <[hidden email]> wrote:
> Thanks Simone!
>
> I got it working and sending requests to an http-spdy connector. Out of
> curiosity, is there way to get it to send requests to an npn connector?

What do you mean ?
There is no such a thing as an NPN connector.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.
_______________________________________________
jetty-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/jetty-users


Hi,

On Mon, Nov 4, 2013 at 7:44 PM, Nicholas Lun <[hidden email]> wrote:
> Thanks Simone!
>
> I got it working and sending requests to an http-spdy connector. Out of
> curiosity, is there way to get it to send requests to an npn connector?

What do you mean ?
There is no such a thing as an NPN connector.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.
_______________________________________________
jetty-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/jetty-users


Hi,

On Mon, Nov 4, 2013 at 7:44 PM, Nicholas Lun <[hidden email]> wrote:
> Thanks Simone!
>
> I got it working and sending requests to an http-spdy connector. Out of
> curiosity, is there way to get it to send requests to an npn connector?

What do you mean ?
There is no such a thing as an NPN connector.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.
_______________________________________________
jetty-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] Sending Http requests over Spdy

Simone Bordet-2
Hi,

On Mon, Nov 4, 2013 at 11:41 PM, Nicholas Lun <[hidden email]> wrote:
> Apologies, I meant the following.
>
> If I initialize my connector like so it works.
>
> HTTPSPDYServerConnectionFactory spdy3 = new
> HTTPSPDYServerConnectionFactory(SPDY.V3, new HttpConfiguration(), new
> PushStrategy.None());
> ServerConnector spdyClientConnector = new ServerConnector(_jetty, spdy3);

Ok, so this sets up a clear-text http-over-spdy connector.
You should use the appropriate connector subclass instead:

ServerConnector spdyConnector = new HTTPSPDYServerConnector(_jetty,
SPDY.V3, new HttpConfiguration(), new PushStrategy.None());

> However, if I set up a spdy connector to have fallbacks like in this
> example:
> http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/examples/embedded/src/main/java/org/eclipse/jetty/embedded/SpdyConnector.java
>
> I get a "400: Bad Message" error when I send a request to it via httpclient
> over spdy. The only difference with on the client side is that the
> httpclient is passed an sslContextFactory as a parameter)

You must make sure that if you are encrypting on the client side, you
also are on the server side.
Please use HTTPSPDYServerConnector; it does all the required magic to
setup NPN for you.

Let us know if it worked.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.
_______________________________________________
jetty-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] Sending Http requests over Spdy

Nicholas Lun
This post was updated on .
Okay, I swapped the server connector for a HTTPSPDYServerConnector. It finds the connection but eventually times out and sends back a 400 bad message. From the log snippets below I'm assuming that the npnserverconnection is selecting http/1.1 when in fact should be selecting a version of spdy?

DEBUG 2013-11-07 13:14:49,473 [org.eclipse.jetty.io.SelectorManager qtp1819749328-42-acceptor-0-HTTPSPDYServerConnector@336e8a49{SSL-npn}{0.0.0.0:8092}] Queued change org.eclipse.jetty.io.SelectorManager$ManagedSelector$Accept@390f9eb5
DEBUG 2013-11-07 13:14:49,473 [org.eclipse.jetty.io.SelectorManager qtp1819749328-30-selector-ServerConnectorManager@3ea7f915/0] Selector loop woken up from select, 0/0 selected
DEBUG 2013-11-07 13:14:49,473 [org.eclipse.jetty.io.SelectorManager qtp1819749328-30-selector-ServerConnectorManager@3ea7f915/0] Running change org.eclipse.jetty.io.SelectorManager$ManagedSelector$Accept@390f9eb5
DEBUG 2013-11-07 13:14:49,483 [org.eclipse.jetty.io.AbstractEndPoint qtp1819749328-30-selector-ServerConnectorManager@3ea7f915/0] onOpen SelectChannelEndPoint@6a8ba7d9{/127.0.0.1:61516<->8092,Open,in,out,-,-,30000,null}{io=0,kio=0,kro=0}
...
DEBUG 2013-11-07 13:14:49,512 [org.eclipse.jetty.spdy.server.NPNServerConnection qtp1819749328-56] NPNServerConnection@3dd8de02{FILLING} protocol selected http/1.1
...
DEBUG 2013-11-07 13:14:49,565 [org.eclipse.jetty.io.ssl.SslConnection qtp1819749328-56] SslConnection@5a124d9f{NEED_UNWRAP,eio=-1/-1,di=-1} -> NPNServerConnection@3dd8de02{FILLING} fill exit
DEBUG 2013-11-07 13:14:49,594 [org.eclipse.jetty.server.HttpConnection qtp1819749328-56] New HTTP Connection HttpConnection@1a239ad8{IDLE}
DEBUG 2013-11-07 13:14:49,595 [org.eclipse.jetty.spdy.server.NPNServerConnection qtp1819749328-56] NPNServerConnection@3dd8de02{FILLING} switching from NPNServerConnection@3dd8de02{FILLING} to HttpConnection@1a239ad8{IDLE}
DEBUG 2013-11-07 13:14:49,595 [org.eclipse.jetty.io.AbstractConnection qtp1819749328-56] onClose NPNServerConnection@3dd8de02{FILLING}
DEBUG 2013-11-07 13:14:49,595 [org.eclipse.jetty.io.AbstractConnection qtp1819749328-56] onOpen HttpConnection@1a239ad8{IDLE}
Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] Sending Http requests over Spdy

Simone Bordet-2
Hi,

On Thu, Nov 7, 2013 at 10:30 PM, Nicholas Lun <[hidden email]> wrote:
> Okay, I swapped the server connector for a HTTPSPDYServerConnector. It finds
> the connection but eventually times out and sends back a 400 bad message.
> From the log snippets below I'm assuming that the npnconnector is selecting
> http/1.1 when in fact should be selecting a version of spdy?

All right I misunderstood what you were trying to do.

If you setup HttpClient to speak SPDY, it will speak SPDY only.
Currently HttpClient setup in that way does not negotiate the protocol
via NPN because it can only speak SPDY.
Since it does not send the the NPN extension via TLS, the server
assumes HTTP/1.1, which is obviously wrong, as the client speaks SPDY.
That's why you get 400 Bad Message.

Currently, there is no implementation of a transport that sends the
NPN extension to the server, and then configures the negotiated
transport based on the NPN negotiation.
Do you need this feature, or you can live with a non-negotiating HttpClient ?

--
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.
_______________________________________________
jetty-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] Sending Http requests over Spdy

Nicholas Lun
Thanks for clearing that up Simone. It would be preferable to have the a client that negotiates, since the point of npn is to have that flexibility on the server side with a single connector. I suppose it would be okay to have multiple connectors for now, but I would definitely want to simplify it to a single connector in the future.