Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Testing jetty http/3 server

Hi,

On Tue, Oct 11, 2022 at 9:09 AM Mateusz K. <matkoz1988@xxxxxxxxx> wrote:
>
> Hello,
> I'm learning jetty programming and have a problem with running a basic HTTP/3 server.
> Here's what i did: I added http3-server to my project's pom.xml file, added few lines to the main() function:
>
> Server server = new Server();
>
> SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
> sslContextFactory.setKeyStorePath("/home/test/keystore.p12");
> sslContextFactory.setKeyStorePassword("passwd");
> sslContextFactory.setCertAlias("jetty");
>
> Session.Server.Listener sessionListener = new Session.Server.Listener() {};
>
> RawHTTP3ServerConnectionFactory http3 = new RawHTTP3ServerConnectionFactory(sessionListener);
> http3.getHTTP3Configuration().setStreamIdleTimeout(15000);
>
> HTTP3ServerConnector connector = new HTTP3ServerConnector(server, sslContextFactory, http3);
> connector.getQuicConfiguration().setMaxBidirectionalRemoteStreams(1024);
> connector.setPort(8181);
>
> server.addConnector(connector);
> server.start();
>
> Now, when server.start() is called i can see messages stating that the server has started:
> 2022-10-11 09:04:22.670:INFO :oejs.AbstractConnector:main: Started HTTP3ServerConnector@7276c8cd{h3, (h3)}{0.0.0.0:8181}
> 2022-10-11 09:04:22.891:INFO :oejs.Server:main: Started Server@50de0926{STARTING}[11.0.12,sto=0] @1353ms
>
> However, if i try to make a new connection to it using HTTP3Client class i'm getting java.nio.channels.ClosedChannelException
>
> I'm following this guide: https://www.eclipse.org/jetty/documentation/jetty-11/programming_guide.php
> Any suggestions as to what I'm missing here would be very appreciated. For now I want only the client to establish a connection with the h3 server. thanks in advance

Show also your client code.

With a completely empty Session.Server.Listener, you won't be able to
respond to requests, so it'll be natural that eventually the
connection times out.

For complete examples, please see:
https://github.com/eclipse/jetty.project/blob/jetty-11.0.12/jetty-http3/http3-tests/src/test/java/org/eclipse/jetty/http3/tests/ClientServerTest.java#L150

-- 
Simone Bordet
---
Finally, no matter how good the architecture and design are,
to deliver bug-free software with optimal performance and reliability,
the implementation technique must be flawless.   Victoria Livschitz


Back to the top