HTTP protocol handling configuration
HTTP protocol handling configuration
HTTP compression parameters only applies to HTTP request and responses and not web sockets.
Maximum size of HTTP request in megabytes. Defaults to 4MB.
Maximum size the initial line. Defaults to 4096 characters.
Maximum size of HTTP headers. Defaults to 8192 bytes.
Maximum size of HTTP chunks. Defaults to 8192 bytes.
Flag to indicate if we want to aggregate chunks. If false, your processor actors must be
able to handle HttpChunkProcessingContext
Minimum number of bytes before HTTP content will be compressed if requested
by the client. Set to -1 to turn off compression for all files; 0 to make all content compressible.
Maximum number of bytes before HTTP content will be not be compressed if requested by the client. Defaults to 1MB otherwise too much CPU maybe taken up for compression.
List of MIME types of that can be compressed. If not supplied, defaults to HTML, CSS, JSON, XML and Javascript files.
Support SPDY protocol or not. Defaults to false.
Creates a new channel pipeline for each Netty channel (network connection)
Handler used with SPDY that performs protocol negotiation.
Handler used with SPDY that performs protocol negotiation.
Once Jetty's NextProtoNego returns the selected protocol, we setup the pipeline accordingly.
Code ported from post form Jos Dirksen and Netty SpdyOrHttpChooser class
Handles incoming HTTP messages from Netty
SSL Configuration
SSL Configuration
Path to server private key store file (server certificates)
Password to access server private key store file.
Path to key store file for trusted remote public keys (client certificates). This is optional.
Password to access the key store for trusted remote public keys (client certificates). This is optional.
Manages reading key stores and trust stores for TLS/SSL connections
TCP IP configuration as per Netty.
TCP IP configuration as per Netty.
See javadoc and netty doc for more information.
Netty and JVM defaults are used until overriden here.
Disable Nagle's algorithm. Defaults to true if not supplied.
Set a hint the size of the underlying buffers for outgoing network I/O.
Get the size of the buffer actually used by the platform when receiving in data on this socket.
Turn on socket keep-alive. Defaults to false if not supplied.
Enable reuse address for a socket and not throw an "already bind exception" The default value is JVM specific.
Specify a linger-on-close timeout.
Sets the type-of-service or traffic class field in the IP header for a TCP or UDP socket. \ The default value is JVM specific.
The number of requests that can be queued. Useful in managing sudden bursts in requests. If take an example with a socket server invoker that has max pool set to 300, accept threads is 2, and backlog is 200, will be able to make 502 concurrent client calls. The 503rd client request will get an exception immediately. However, this does not mean all 502 requests will be guaranteed to be processed, only the first 300 (as they have server threads available to do the processing). If 202 of the server threads finish processing their requests from their initial client connections and the connection is released before the timeout for the other 202 that are waiting (200 for backlog and 2 for accept thread), then they will be processed (of course this is a request by request determination).
Configuration for web server activity logs.
Configuration for web server activity logs.
Optional path of actor to which org.mashupbots.socko.infrastructure.WebLogEvent will be sent for writing. If this path is not present, org.mashupbots.socko.infrastructure.WebLogWriter will be used.
Format of the web log. Defaults to Common.
Socko Web Server
Socko Web Server
val webServer = new WebServer(myWebServerConfig, actorSystem, { server => new RequestHandler(server, routes) }) webServer.start() ... webServer.stop()
Web server configuration
Web server configuration
The configuration can be optionally loaded from Akka's application.conf file.
The following example configuration file:
akka-config-example {
server-name=AkkaConfigExample
hostname=localhost
port=9000
idle-connection-timeout=0
log-network-activity=false
# Optional web log. If not supplied, web server activity logging is turned off.
web-log {
# Optional path of actor to which web log events will be sent for writing. If not specified, the default
# web log writer will be created
custom-actor-path = "akka://my-system/user/web-log-writer"
# Optional web log format for the default web log writer: Common, Combined or Extended.
# If no specified, Common is the default.
format = Common
}
# Optional SSL. If not supplied, ssl is turned off.
ssl {
# Path to key store (server cert.)
key-store-file=/tmp/ks.dat
# Password to key store
key-store-password=kspwd
# Optional path to trust store (client cert.)
trust-store-file=/tmp/ts.dat
# Optional password to trust store
trust-store-password=tspwd
}
# Optional HTTP protocol configuration. If not supplied, defaults are used.
http {
# Maximum size of HTTP request. Defaults to 4MB.
max-length-in-mb=4
# Maximum length of the HTTP initial line. Defaults to 4096 bytes (4K).
max-initial-line-length=4096
# Maximum size of HTTP headers. Defaults to 8192 bytes (8K).
max-header-size-in-bytes=8192
# Maximum size of HTTP chunks. Defaults to 8192 bytes (8K).
max-chunk-size-in-bytes=8192
# Flag to indicate if HTTP chunk requests should be aggregated and presented
# as a single HTTP request. Defaults to true.
aggregate-chunks=true
# Content under this size is not compressed. Defaults to 1024 bytes (1K).
# Set to -1 to turn off compression; or 0 to compress all content.
min-compressible-content-size-in-bytes=1024
# Content over this size is not compressed. Defaults to 1MB
max-compressible-content-size-in-bytes=60
# Only content with the specified MIME type will be compressed
compressible-content-types=[
"text/plain", "text/html", "text/xml", "text/css",
"application/xml", "application/xhtml+xml", "application/rss+xml",
"application/json", "application/jsonml+json",
"application/javascript", "application/x-javascript"]
# Enable SPDY protocol or not. Defaults to `false`. If `true`, you must also enable SSL.
spdy=false
}
# Optional TCP protocol configuration. If not supplied, defaults are used.
tcp {
# Disable Nagle's algorithm. Defaults to `true` if not supplied.
no-delay=
# Set a hint the size of the underlying buffers for outgoing network I/O.
send-buffer-size=
# Get the size of the buffer actually used by the platform when receiving in data on this socket
receive-buffer-size=
# Turn on socket keep-alive. `true` or `false`.
keep-alive=
# Enable reuse address for a socket and not throw an "already bind exception". `true` or `false`.
reuse-address=
# Specify a linger-on-close timeout.
so-linger=
# Sets the type-of-service or traffic class field in the IP header for a TCP or UDP socket.
traffic-class=
# The number of requests that can be queued.
accept-backlog=
}
}can be loaded as follows:
object MyWebServerConfig extends ExtensionId[WebServerConfig] with ExtensionIdProvider { override def lookup = MyWebServerConfig override def createExtension(system: ExtendedActorSystem) = new WebServerConfig(system.settings.config, "akka-config-example") } val myWebServerConfig = MyWebServerConfig(actorSystem) val webServer = new WebServer(myWebServerConfig, routes) webServer.start()
Human friendly name of this server. Defaults to WebServer.
Hostname or IP address to bind. 0.0.0.0 will bind to all addresses.
You can also specify comma separated hostnames/ip address like localhost,192.168.1.1.
Defaults to localhost.
IP port number to bind to. Defaults to 8888.
If a connection is idle for this duration, it will be closed. The default is 0,
which indicates NO timeout and idle connections will NOT be closed.
Dumps request and response data to the debug logger. To see the output, you need to
set the logging level for io.netty.handler.logging.LoggingHandler to debug. The default is false.
Optional web log configuration. If None, web log events will NOT be generated.
SSL protocol configuration. If None, then SSL will not be turned on.
Defaults to None.
HTTP protocol configuration. Defaults to an instance of org.mashupbots.socko.webserver.HttpConfig with default settings.
TCP IP protocol configuration. Defaults to an instance of org.mashupbots.socko.webserver.TcpConfig with default settings.
Manages all web socket connections
Manages all web socket connections
Acts as a wrapper for Netty's channel group. A TODO is to optimize performance by using a hash lookup.
Methods for reading configuration from Akka.
Socko web server built on top of Netty networking and Akka processing.