You are viewing the documentation for the 2.7.3 release in the 2.7.x series of releases. The latest stable release series is 3.0.x.
§Configuring Netty Server Backend
The Netty server backend is built on top of Netty.
Note: The Netty server backend is not the default in 2.6.x, and so must be specifically enabled. See more information in Netty Server documentation.
§Default configuration
Play uses the following default configuration:
play.server {
# The server provider class name
provider = "play.core.server.NettyServerProvider"
netty {
# The default value of the `Server` header to produce if no explicit `Server`-header was included in a response.
# If this value is the null and no header was included in the request, no `Server` header will be rendered at all.
server-header = null
server-header = ${?play.server.server-header}
# The number of event loop threads. 0 means let Netty decide, which by default will select 2 times the number of
# available processors.
eventLoopThreads = 0
# The maximum length of the initial line. This effectively restricts the maximum length of a URL that the server will
# accept, the initial line consists of the method (3-7 characters), the URL, and the HTTP version (8 characters),
# including typical whitespace, the maximum URL length will be this number - 18.
maxInitialLineLength = 4096
# The maximum length of the HTTP headers. The most common effect of this is a restriction in cookie length, including
# number of cookies and size of cookie values.
maxHeaderSize = 8192
# The maximum length of body bytes that Netty will read into memory at a time.
# This is used in many ways. Note that this setting has no relation to HTTP chunked transfer encoding - Netty will
# read "chunks", that is, byte buffers worth of content at a time and pass it to Play, regardless of whether the body
# is using HTTP chunked transfer encoding. A single HTTP chunk could span multiple Netty chunks if it exceeds this.
# A body that is not HTTP chunked will span multiple Netty chunks if it exceeds this or if no content length is
# specified. This only controls the maximum length of the Netty chunk byte buffers.
maxChunkSize = 8192
# Whether the Netty wire should be logged
log.wire = false
# The transport to use, either jdk or native.
# Native socket transport has higher performance and produces less garbage but are only available on linux
transport = "jdk"
# Netty options. Possible keys here are defined by:
#
# http://netty.io/4.1/api/io/netty/channel/ChannelOption.html
# For native socket transport:
# https://netty.io/4.1/api/io/netty/channel/unix/UnixChannelOption.html
# https://netty.io/4.1/api/io/netty/channel/epoll/EpollChannelOption.html
#
# Options that pertain to the listening server socket are defined at the top level, options for the sockets associated
# with received client connections are prefixed with child.*
option {
# Set the size of the backlog of TCP connections. The default and exact meaning of this parameter is JDK specific.
# SO_BACKLOG = 100
child {
# Set whether connections should use TCP keep alive
# SO_KEEPALIVE = false
# Set whether the TCP no delay flag is set
# TCP_NODELAY = false
# Example how to set native socket transport options
# (Full qualified class name + "#" + option)
# "io.netty.channel.unix.UnixChannelOption#SO_REUSEPORT" = true
# "io.netty.channel.epoll.EpollChannelOption#TCP_FASTOPEN" = 1
}
}
}
}
The configurations above are specific to Netty server backend, but other more generic configurations are also available:
play {
server {
# The root directory for the Play server instance. This value can
# be set by providing a path as the first argument to the Play server
# launcher script. See `ServerConfig.loadConfiguration`.
dir = ${?user.dir}
# HTTP configuration
http {
# The HTTP port of the server. Use a value of "disabled" if the server
# shouldn't bind an HTTP port.
port = 9000
port = ${?PLAY_HTTP_PORT}
port = ${?http.port}
# The interface address to bind to.
address = "0.0.0.0"
address = ${?PLAY_HTTP_ADDRESS}
address = ${?http.address}
# The idle timeout for an open connection after which it will be closed
# Set to null or "infinite" to disable the timeout, but notice that this
# is not encouraged since timeout are important mechanisms to protect your
# servers from malicious attacks or programming mistakes.
idleTimeout = 75 seconds
}
# HTTPS configuration
https {
# The HTTPS port of the server.
port = ${?PLAY_HTTPS_PORT}
port = ${?https.port}
# The interface address to bind to
address = "0.0.0.0"
address = ${?PLAY_HTTPS_ADDRESS}
address = ${?https.address}
# The idle timeout for an open connection after which it will be closed
# Set to null or "infinite" to disable the timeout, but notice that this
# is not encouraged since timeout are important mechanisms to protect your
# servers from malicious attacks or programming mistakes.
idleTimeout = ${play.server.http.idleTimeout}
# The SSL engine provider
engineProvider = "play.core.server.ssl.DefaultSSLEngineProvider"
engineProvider = ${?play.http.sslengineprovider}
# HTTPS keystore configuration, used by the default SSL engine provider
keyStore {
# The path to the keystore
path = ${?https.keyStore}
# The type of the keystore
type = "JKS"
type = ${?https.keyStoreType}
# The password for the keystore
password = ""
password = ${?https.keyStorePassword}
# The algorithm to use. If not set, uses the platform default algorithm.
algorithm = ${?https.keyStoreAlgorithm}
}
# HTTPS truststore configuration
trustStore {
# If true, does not do CA verification on client side certificates
noCaVerification = false
}
# Whether JSSE want client auth mode should be used. This means, the server
# will request a client certificate, but won't fail if one isn't provided.
wantClientAuth = false
# Whether JSSE need client auth mode should be used. This means, the server
# will request a client certificate, and will fail and terminate the session
# if one isn't provided.
needClientAuth = false
}
# The path to the process id file created by the server when it runs.
# If set to "/dev/null" then no pid file will be created.
pidfile.path = ${play.server.dir}/RUNNING_PID
pidfile.path = ${?pidfile.path}
websocket {
# Maximum allowable frame payload length. Setting this value to your application's
# requirement may reduce denial of service attacks using long data frames.
frame.maxLength = 64k
frame.maxLength = ${?websocket.frame.maxLength}
}
debug {
# If set to true this will attach an attribute to each request containing debug information. If the application
# fails to load (e.g. due to a compile issue in dev mode), then this configuration value is ignored and the debug
# information is always attached.
#
# Note: This configuration option is not part of Play's public API and is subject to change without the usual
# deprecation cycle.
addDebugInfoToRequests = false
}
}
editor = ${?PLAY_EDITOR}
}
§Configuring transport socket
Native socket transport has higher performance and produces less garbage but is only available on Linux. You can configure the transport socket type in application.conf
:
play.server {
netty {
transport = "native"
}
}
§Configuring channel options
The available options are defined in Netty channel option documentation. If you are using native socket transport you can set these and these additional options.
Next: Configuring logging