Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Jetty/Howto/Configure Connectors"

< Jetty‎ | Howto
m (border in table makes it easier to read)
 
(12 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
{{Jetty Howto
 
{{Jetty Howto
 
| introduction =  
 
| introduction =  
.
+
 
| examples =
+
{{Jetty Redirect|http://www.eclipse.org/jetty/documentation/current/configuring-connectors.html#jetty-connectors}}
 +
 
 +
Jetty provides several types of connectors that allow you to tailor the server setup to suit your circumstances.
 +
| steps =
 
==Types of Connectors==
 
==Types of Connectors==
  
===org.eclipse.jetty.server.nio.SelectChannelConnector===
+
===SelectChannelConnector===
  
This connector uses efficient NIO buffers with a non blocking threading model. Direct NIO buffers are used and threads are only allocated to connections with requests. Synchronization is used to simulate blocking for the servlet API, and any unflushed content at the end of request handling is written asynchronously.
+
This connector uses efficient NIO buffers with a non-blocking threading model. Jetty uses Direct NIO buffers, and allocates threads only to connections with requests. Synchronization simulates blocking for the servlet API, and any unflushed content at the end of request handling is written asynchronously. See [http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/server/nio/SelectChannelConnector.html javadoc].
  
 
This connector is best used when there are a many connections that have idle periods.
 
This connector is best used when there are a many connections that have idle periods.
  
When used with [[Jetty/Feature/Continuations|Continuations]], threadless waits are supported. When a filter or servlet calls getEvent on a Continuation, a runtime exception is thrown to allow the thread to exit the current request handling. Jetty will catch this exception and will not send a response to the client. Instead the thread is released and the Continuation is placed on the timer queue. If the Continuation timeout expires, or it's resume method is called, then the request is again allocated a thread and the request is retried. The limitation of this approach is that request content is not available on the retried request, thus if possible it should be read after the continuation or saved as a request attribute or as the associated object of the Continuation instance.
+
When used with [[Jetty/Feature/Continuations|Continuations]], threadless waits are supported. When a filter or servlet calls getEvent on a Continuation, a runtime exception is thrown to allow the thread to exit the current request handling. Jetty catches this exception and does not send a response to the client. Instead Jetty releases the thread and places the Continuation on the timer queue. If the Continuation timeout expires, or its resume method is called, then Jetty again allocates a thread to the request, and the request retries. The limitation of this approach is that request content is not available on the retried request, thus if possible it should be read after the Continuation or saved as a request attribute or as the associated object of the Continuation instance.
  
===org.eclipse.jetty.server.bio.SocketConnector===
+
===SocketConnector===
  
This connector implements a traditional blocking IO and threading model. Normal JRE sockets are used and a thread is allocated per connection. Buffers are managed so that large buffers are only allocated to active connections. This Connector should only be used if NIO is not available.
+
This connector implements a traditional blocking IO and threading model. Jetty uses Normal JRE sockets and allocates a thread per connection. Jetty allocates large buffers to active connections only. You should use this Connector only if NIO is not available. See [http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/server/bio/SocketConnector.html javadoc].
  
===org.eclipse.jetty.server.ssl.SslSelectChannelConnector===
+
===SslSelectChannelConnector===
  
SSL connector using NIO. More information about it's configuration can be found on the [[Jetty/Reference/SSL+Connectors|SSL Connector Reference]] page.
+
This is an SSL connector that uses NIO. For more information about its configuration, see [[Jetty/Reference/SSL Connectors|SSL Connector Reference]]. See also [http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.html javadoc].
  
===org.eclipse.jetty.server.ssl.SslSocketConnector===
+
===SslSocketConnector===
  
Blocking IO connector supporting SSL.
+
This is a blocking IO connector that supports SSL. See [http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/server/ssl/SslSocketConnector.html javadoc].
  
===org.eclipse.jetty.ajp.Ajp13SocketConnector===
+
===Ajp13SocketConnector===
  
Connector implementing the AJP13 protocol. See [[Jetty/Howto/Configure AJP13|How to Configure Ajp13]] for more information, and also take a look at [[JETTY/Howto/Configure mod_proxy|How to Configure mod_proxy]] for alternatives to using the AJP13 protocol.
+
This connector implements the AJP13 protocol. See [[Jetty/Howto/Configure AJP13|How to Configure Ajp13]] for more information, and also take a look at [[JETTY/Howto/Configure mod_proxy|How to Configure mod_proxy]] for alternatives to using the AJP13 protocol. See also [http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/ajp/Ajp13SocketConnector.html javadoc].
  
 
==Configuration Options==
 
==Configuration Options==
<table>
+
<table border="1">
 
<tr>
 
<tr>
 
<td>acceptors</td>
 
<td>acceptors</td>
Line 48: Line 51:
 
</tr><tr>
 
</tr><tr>
 
<td>forwarded</td>
 
<td>forwarded</td>
<td>If true use <tt>hostHeader</tt> or else check the headers for retrieving information from the original request to control what is returned by <tt>ServletRequest#getServerName()</tt> and <tt>ServletRequest#getServerPort()</tt> and <tt>ServletRequest#getRemoteAddr()</tt> (see [[Jetty/Howto/Configure+mod_proxy|How to Configure mod_proxy]). Default is false.</td>
+
<td>If true use <tt>hostHeader</tt> or else check the headers for retrieving information from the original request to control what <tt>ServletRequest#getServerName()</tt> and <tt>ServletRequest#getServerPort()</tt> and <tt>ServletRequest#getRemoteAddr()</tt> return. Default is false. See [[Jetty/Howto/Configure mod_proxy|How to Configure mod_proxy]]. </td>
 
</tr><tr>
 
</tr><tr>
 
<td>forwardedHostHeader</td>
 
<td>forwardedHostHeader</td>
<td>The forwarded <tt>Host</tt> header to use. Default is <tt>X-Forwarded-Host</tt>. This value is only used if <tt>forwarded</tt> is true.</td>
+
<td>The forwarded <tt>Host</tt> header to use. Default is <tt>X-Forwarded-Host</tt>. This value is used only if <tt>forwarded</tt> is true.</td>
 
</tr><tr>
 
</tr><tr>
 
<td>forwardedServerHeader</td>
 
<td>forwardedServerHeader</td>
<td>The forwarded server name header to use. Default is <tt>X-Forwarded-Server</tt>. This value is only used if <tt>forwarded</tt> is true.</td>
+
<td>The forwarded server name header to use. Default is <tt>X-Forwarded-Server</tt>. This value is used only if <tt>forwarded</tt> is true.</td>
 
</tr><tr>
 
</tr><tr>
 
<td>forwardedForHeader</td>
 
<td>forwardedForHeader</td>
<td>The forwarded for header to use. Default is <tt>X-Forwarded-For</tt>. This value is only used if <tt>forwarded</tt> is true.</td>
+
<td>The forwarded for header to use. Default is <tt>X-Forwarded-For</tt>. This value is used only if <tt>forwarded</tt> is true.</td>
</tr><tr>
+
<td>headerBufferSize</td>
+
<td>Set the size of the buffer to be used for request and response headers. An idle connection will at most have one buffer of this size allocated. Default is 4K.</td>
+
 
</tr><tr>
 
</tr><tr>
 
<td>hostHeader</td>
 
<td>hostHeader</td>
<td>Set a forced valued for the <tt>Host</tt> header to control what is returned by <tt>ServletRequest#getServerName()</tt> and <tt>ServletRequest#getServerPort()</tt>. This value is only used if <tt>forwarded</tt> is true.</td>
+
<td>Set a forced valued for the <tt>Host</tt> header to control what <tt>ServletRequest#getServerName()</tt> and <tt>ServletRequest#getServerPort()</tt> return. This value is used only if <tt>forwarded</tt> is true.</td>
 
</tr><tr>
 
</tr><tr>
 
<td>host</td>
 
<td>host</td>
<td>The particular interface to listen on. If not set or 0.0.0.0, jetty will listen on <tt>port</tt> on all interfaces.</td>
+
<td>The particular interface to listen on. If not set or 0.0.0.0, Jetty listens on <tt>port</tt> on all interfaces.</td>
 
</tr><tr>
 
</tr><tr>
 
<td>integralPort</td>
 
<td>integralPort</td>
Line 72: Line 72:
 
</tr><tr>
 
</tr><tr>
 
<td>lowResourcesConnections</td>
 
<td>lowResourcesConnections</td>
<td>Set the number of connections, which if exceeded places this connector in a low resources state. This is not an exact measure as the connection count is averaged over the select sets. When in a low resources state, different idle timeouts can apply on connections (see <tt>lowResourcesMaxIdleTime</tt>.</td>
+
<td>Sets the number of connections, which if exceeded places this connector in a low resources state. This is not an exact measure as the connection count is averaged over the select sets. When in a low resources state, different idle timeouts can apply on connections. See <tt>lowResourcesMaxIdleTime</tt>.</td>
 
</tr><tr>
 
</tr><tr>
 
<td>lowResourcesMaxIdleTime</td>
 
<td>lowResourcesMaxIdleTime</td>
<td>Set the period in ms that a connection is allowed to be idle when this there are more than <tt>lowResourcesConnections</tt> connections. This allows the server to rapidly close idle connections in order to gracefully handle high load situations.</td>
+
<td>Sets the period in ms that a connection is allowed to be idle when this there are more than <tt>lowResourcesConnections</tt> connections. This allows the server to rapidly close idle connections in order to gracefully handle high load situations.</td>
 
</tr><tr>
 
</tr><tr>
 
<td>maxIdleTime</td>
 
<td>maxIdleTime</td>
<td>Set the maximum Idle time for a connection, which roughly translates to the Socket.setSoTimeout(int) call, although with NIO implementations other mechanisms may be used to implement the timeout. The max idle time is applied: when waiting for a new request to be received on a connection; when reading the headers and content of a request; when writing the headers and content of a response. Jetty interprets this value as the maximum time between some progress being made on the connection. So if a single byte is read or written, then the timeout (if implemented by jetty) is reset. However, in many instances, the reading/writing is delegated to the JVM, and the semantic is more strictly enforced as the maximum time a single read/write operation can take. Note, that as Jetty supports writes of memory mapped file buffers, then a write may take many 10s of seconds for large content written to a slow device.</td>
+
<td>Set the maximum Idle time for a connection, which roughly translates to the Socket.setSoTimeout(int) call, although with NIO implementations other mechanisms may be used to implement the timeout. The max idle time is applied: when waiting for a new request to be received on a connection; when reading the headers and content of a request; when writing the headers and content of a response. Jetty interprets this value as the maximum time between some progress being made on the connection. So if a single byte is read or written, then the timeout (if implemented by Jetty) is reset. However, in many instances, the reading/writing is delegated to the JVM, and the semantic is more strictly enforced as the maximum time a single read/write operation can take. Note that as Jetty supports writes of memory-mapped file buffers, a write may take many 10s of seconds for large content written to a slow device.</td>
 
</tr><tr>
 
</tr><tr>
 
<td>name</td>
 
<td>name</td>
<td>The name of the connector. Can be used to make a WebAppContext respond only to requests on the named connector via the WebAppContext.setConnectorNames(String[]) method</td>
+
<td>The name of the connector. Can be used to make a WebAppContext respond only to requests on the named connector via the <tt>WebAppContext.setConnectorNames(String[])</tt> method</td>
 
</tr><tr>
 
</tr><tr>
 
<td>port</td>
 
<td>port</td>
<td>The port to listen on. See also <tt>host</tt></td>
+
<td>The port to listen on. See also <tt>host</tt>.</td>
 
</tr><tr>
 
</tr><tr>
 
<td>requestBufferSize</td>
 
<td>requestBufferSize</td>
<td>Set the size of the content buffer for receiving requests. These buffers are only used for active connections that have requests with bodies that will not fit within the header buffer (see <tt>headerBufferSize</tt>). Default is 8K.</td>
+
<td>Sets the size of the content buffer for receiving requests. These buffers are used only for active connections that have requests with bodies that do not fit within the header buffer (see <tt>requestHeaderSize</tt>). Default is 8K.</td>
 +
</tr><tr>
 +
<td>requestHeaderSize</td>
 +
<td>Sets the size of the buffer for request headers. An idle connection at most has one buffer of this size allocated. Default is 6K.</td>
 
</tr><tr>
 
</tr><tr>
 
<td>responseBufferSize</td>
 
<td>responseBufferSize</td>
<td>Set the size of the content buffer for sending responses. These buffers are only used for active connections that are sending responses with bodies that will not fit within the header buffer. Default is 32K.</td>
+
<td>Sets the size of the content buffer for sending responses. These buffers are used only for active connections that are sending responses with bodies that will not fit within the header buffer. Default is 32K.</td>
 +
</tr><tr>
 +
<td>responseHeaderSize</td>
 +
<td>Sets the size of the buffer for response headers. Default is 6K.</td>
 
</tr><tr>
 
</tr><tr>
 
<td>resolveNames</td>
 
<td>resolveNames</td>
<td>If true, request IP addresses will be resolved to host names</td>
+
<td>If true, request IP addresses will be resolved to host names.</td>
 
</tr><tr>
 
</tr><tr>
 
<td>reuseAddress</td>
 
<td>reuseAddress</td>
<td>True if the the server socket will be opened in SO_REUSEADDR mode</td>
+
<td>True if the the server socket will be opened in SO_REUSEADDR mode.</td>
 
</tr><tr>
 
</tr><tr>
<td></td>
+
<td> soLingerTime </td>
 
<td>Sets SO_LINGER on the connection socket. Disabled by default.</td>
 
<td>Sets SO_LINGER on the connection socket. Disabled by default.</td>
 
</tr><tr>
 
</tr><tr>
 
<td>statsOn</td>
 
<td>statsOn</td>
<td>If true, enables statistics collection on connections see [[Jetty/Feature/Statistics|Statistics]]</td>
+
<td>If true, enables statistics collection on connections. See [[Jetty/Feature/Statistics|Statistics]].</td>
 
</tr><tr>
 
</tr><tr>
 
<td>useDirectBuffers</td>
 
<td>useDirectBuffers</td>

Latest revision as of 08:57, 30 May 2014



Introduction

Warning2.png
Jetty 7 and Jetty 8 are now EOL (End of Life)




THIS IS NOT THE DOCUMENTATION YOU ARE LOOKING FOR!!!!!






All development and stable releases are being performed with Jetty 9 and Jetty 10.






This wiki is now officially out of date and all content has been moved to the Jetty Documentation Hub






Direct Link to updated documentation: http://www.eclipse.org/jetty/documentation/current/configuring-connectors.html#jetty-connectors


Jetty provides several types of connectors that allow you to tailor the server setup to suit your circumstances.


Steps

Types of Connectors

SelectChannelConnector

This connector uses efficient NIO buffers with a non-blocking threading model. Jetty uses Direct NIO buffers, and allocates threads only to connections with requests. Synchronization simulates blocking for the servlet API, and any unflushed content at the end of request handling is written asynchronously. See javadoc.

This connector is best used when there are a many connections that have idle periods.

When used with Continuations, threadless waits are supported. When a filter or servlet calls getEvent on a Continuation, a runtime exception is thrown to allow the thread to exit the current request handling. Jetty catches this exception and does not send a response to the client. Instead Jetty releases the thread and places the Continuation on the timer queue. If the Continuation timeout expires, or its resume method is called, then Jetty again allocates a thread to the request, and the request retries. The limitation of this approach is that request content is not available on the retried request, thus if possible it should be read after the Continuation or saved as a request attribute or as the associated object of the Continuation instance.

SocketConnector

This connector implements a traditional blocking IO and threading model. Jetty uses Normal JRE sockets and allocates a thread per connection. Jetty allocates large buffers to active connections only. You should use this Connector only if NIO is not available. See javadoc.

SslSelectChannelConnector

This is an SSL connector that uses NIO. For more information about its configuration, see SSL Connector Reference. See also javadoc.

SslSocketConnector

This is a blocking IO connector that supports SSL. See javadoc.

Ajp13SocketConnector

This connector implements the AJP13 protocol. See How to Configure Ajp13 for more information, and also take a look at How to Configure mod_proxy for alternatives to using the AJP13 protocol. See also javadoc.

Configuration Options

acceptors The number of thread dedicated to accepting incoming connections.
acceptQueueSize Number of connection requests that can be queued up before the operating system starts to send rejections.
acceptorPriority Sets the priority of the acceptor threads relative to the other threads.
confidentialPort The port to redirect to if there is a security constraint of CONFIDENTIAL.
confidentialScheme https by default
forwarded If true use hostHeader or else check the headers for retrieving information from the original request to control what ServletRequest#getServerName() and ServletRequest#getServerPort() and ServletRequest#getRemoteAddr() return. Default is false. See How to Configure mod_proxy.
forwardedHostHeader The forwarded Host header to use. Default is X-Forwarded-Host. This value is used only if forwarded is true.
forwardedServerHeader The forwarded server name header to use. Default is X-Forwarded-Server. This value is used only if forwarded is true.
forwardedForHeader The forwarded for header to use. Default is X-Forwarded-For. This value is used only if forwarded is true.
hostHeader Set a forced valued for the Host header to control what ServletRequest#getServerName() and ServletRequest#getServerPort() return. This value is used only if forwarded is true.
host The particular interface to listen on. If not set or 0.0.0.0, Jetty listens on port on all interfaces.
integralPort The port to redirect to if there is a security constraint of INTEGRAL.
lowResourcesConnections Sets the number of connections, which if exceeded places this connector in a low resources state. This is not an exact measure as the connection count is averaged over the select sets. When in a low resources state, different idle timeouts can apply on connections. See lowResourcesMaxIdleTime.
lowResourcesMaxIdleTime Sets the period in ms that a connection is allowed to be idle when this there are more than lowResourcesConnections connections. This allows the server to rapidly close idle connections in order to gracefully handle high load situations.
maxIdleTime Set the maximum Idle time for a connection, which roughly translates to the Socket.setSoTimeout(int) call, although with NIO implementations other mechanisms may be used to implement the timeout. The max idle time is applied: when waiting for a new request to be received on a connection; when reading the headers and content of a request; when writing the headers and content of a response. Jetty interprets this value as the maximum time between some progress being made on the connection. So if a single byte is read or written, then the timeout (if implemented by Jetty) is reset. However, in many instances, the reading/writing is delegated to the JVM, and the semantic is more strictly enforced as the maximum time a single read/write operation can take. Note that as Jetty supports writes of memory-mapped file buffers, a write may take many 10s of seconds for large content written to a slow device.
name The name of the connector. Can be used to make a WebAppContext respond only to requests on the named connector via the WebAppContext.setConnectorNames(String[]) method
port The port to listen on. See also host.
requestBufferSize Sets the size of the content buffer for receiving requests. These buffers are used only for active connections that have requests with bodies that do not fit within the header buffer (see requestHeaderSize). Default is 8K.
requestHeaderSize Sets the size of the buffer for request headers. An idle connection at most has one buffer of this size allocated. Default is 6K.
responseBufferSize Sets the size of the content buffer for sending responses. These buffers are used only for active connections that are sending responses with bodies that will not fit within the header buffer. Default is 32K.
responseHeaderSize Sets the size of the buffer for response headers. Default is 6K.
resolveNames If true, request IP addresses will be resolved to host names.
reuseAddress True if the the server socket will be opened in SO_REUSEADDR mode.
soLingerTime Sets SO_LINGER on the connection socket. Disabled by default.
statsOn If true, enables statistics collection on connections. See Statistics.
useDirectBuffers For nio connectors, determines whether direct byte buffers will be used or not. The default is true.
threadPool Sets the thread pool instance. By default this is the thread pool set on the org.eclipse.jetty.server.Server instance, and is a org.eclipse.jetty.util.thread.QueuedThreadPool instance.

Back to the top