use of org.eclipse.jetty.server.ConnectionFactory in project jetty.project by eclipse.
the class DirectHTTP2OverTLSTest method startServer.
private void startServer(Handler handler) throws Exception {
QueuedThreadPool serverThreads = new QueuedThreadPool();
serverThreads.setName("server");
server = new Server(serverThreads);
HttpConfiguration httpsConfig = new HttpConfiguration();
httpsConfig.addCustomizer(new SecureRequestCustomizer());
ConnectionFactory h2 = new HTTP2ServerConnectionFactory(httpsConfig);
ConnectionFactory ssl = new SslConnectionFactory(newSslContextFactory(), h2.getProtocol());
connector = new ServerConnector(server, 1, 1, ssl, h2);
server.addConnector(connector);
server.setHandler(handler);
server.start();
}
use of org.eclipse.jetty.server.ConnectionFactory in project jetty.project by eclipse.
the class ALPNServerConnection method select.
@Override
public String select(List<String> clientProtocols) {
SSLEngine sslEngine = getSSLEngine();
List<String> serverProtocols = getProtocols();
SSLSession sslSession = sslEngine.getHandshakeSession();
if (sslSession == null)
sslSession = sslEngine.getSession();
String tlsProtocol = sslSession.getProtocol();
String tlsCipher = sslSession.getCipherSuite();
String negotiated = null;
// that it prefers that is also supported by the client.
for (String serverProtocol : serverProtocols) {
if (clientProtocols.contains(serverProtocol)) {
ConnectionFactory factory = getConnector().getConnectionFactory(serverProtocol);
if (factory instanceof CipherDiscriminator && !((CipherDiscriminator) factory).isAcceptable(serverProtocol, tlsProtocol, tlsCipher)) {
if (LOG.isDebugEnabled())
LOG.debug("{} protocol {} not acceptable to {} for {}/{}", this, serverProtocol, factory, tlsProtocol, tlsCipher);
continue;
}
negotiated = serverProtocol;
break;
}
}
if (negotiated == null) {
if (clientProtocols.isEmpty()) {
negotiated = getDefaultProtocol();
} else {
if (LOG.isDebugEnabled())
LOG.debug("{} could not negotiate protocol among client{} and server{}", this, clientProtocols, serverProtocols);
throw new IllegalStateException();
}
}
if (LOG.isDebugEnabled())
LOG.debug("{} protocol selected {} among client{} and server{}", this, negotiated, clientProtocols, serverProtocols);
setProtocol(negotiated);
ALPN.remove(sslEngine);
return negotiated;
}
use of org.eclipse.jetty.server.ConnectionFactory in project druid by druid-io.
the class JettyServerModule method makeJettyServer.
static Server makeJettyServer(DruidNode node, ServerConfig config) {
final QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMinThreads(config.getNumThreads());
threadPool.setMaxThreads(config.getNumThreads());
threadPool.setDaemon(true);
final Server server = new Server(threadPool);
// Without this bean set, the default ScheduledExecutorScheduler runs as non-daemon, causing lifecycle hooks to fail
// to fire on main exit. Related bug: https://github.com/druid-io/druid/pull/1627
server.addBean(new ScheduledExecutorScheduler("JettyScheduler", true), true);
ServerConnector connector = new ServerConnector(server);
connector.setPort(node.getPort());
connector.setIdleTimeout(Ints.checkedCast(config.getMaxIdleTime().toStandardDuration().getMillis()));
// workaround suggested in -
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=435322#c66 for jetty half open connection issues during failovers
connector.setAcceptorPriorityDelta(-1);
List<ConnectionFactory> monitoredConnFactories = new ArrayList<>();
for (ConnectionFactory cf : connector.getConnectionFactories()) {
monitoredConnFactories.add(new JettyMonitoringConnectionFactory(cf, activeConnections));
}
connector.setConnectionFactories(monitoredConnFactories);
server.setConnectors(new Connector[] { connector });
return server;
}
use of org.eclipse.jetty.server.ConnectionFactory in project spring-boot by spring-projects.
the class JettyReactiveWebServerFactory method createConnector.
private AbstractConnector createConnector(InetSocketAddress address, Server server) {
ServerConnector connector = new ServerConnector(server, this.acceptors, this.selectors);
connector.setHost(address.getHostName());
connector.setPort(address.getPort());
for (ConnectionFactory connectionFactory : connector.getConnectionFactories()) {
if (connectionFactory instanceof HttpConfiguration.ConnectionFactory) {
((HttpConfiguration.ConnectionFactory) connectionFactory).getHttpConfiguration().setSendServerVersion(false);
}
}
return connector;
}
use of org.eclipse.jetty.server.ConnectionFactory in project spring-boot by spring-projects.
the class JettyServletWebServerFactory method createConnector.
private AbstractConnector createConnector(InetSocketAddress address, Server server) {
ServerConnector connector = new ServerConnector(server, this.acceptors, this.selectors);
connector.setHost(address.getHostName());
connector.setPort(address.getPort());
for (ConnectionFactory connectionFactory : connector.getConnectionFactories()) {
if (connectionFactory instanceof HttpConfiguration.ConnectionFactory) {
((HttpConfiguration.ConnectionFactory) connectionFactory).getHttpConfiguration().setSendServerVersion(false);
}
}
return connector;
}
Aggregations