qbits.jet.server

Adapter for the Jetty 9 server, with websocket + core.async support. Derived from ring.adapter.jetty

run-jetty

(run-jetty {:as options, :keys [websocket-handler ring-handler host port max-threads min-threads input-buffer-size max-idle-time ssl-port configurator daemon? ssl? join?], :or {port 80, max-threads 50, min-threads 8, daemon? false, max-idle-time 200000, ssl? false, join? true, input-buffer-size 8192}})

Start a Jetty webserver to serve the given handler according to the supplied options:

  • :port - the port to listen on (defaults to 80)
  • :host - the hostname to listen on
  • :join? - blocks the thread until server ends (defaults to true)
  • :configurator - fn that will be passed the server instance before server.start()
  • :daemon? - use daemon threads (defaults to false)
  • :ssl? - allow connections over HTTPS
  • :ssl-port - the SSL port to listen on (defaults to 443, implies :ssl?)
  • :keystore - the keystore to use for SSL connections
  • :keystore-type - the format of keystore
  • :key-password - the password to the keystore
  • :truststore - a truststore to use for SSL connections
  • :truststore-type - the format of trust store
  • :trust-password - the password to the truststore
  • :max-threads - the maximum number of threads to use (default 50)
  • :max-idle-time - the maximum idle time in milliseconds for a connection (default 200000)
  • :ws-max-idle-time - the maximum idle time in milliseconds for a websocket connection (default 500000)
  • :client-auth - SSL client certificate authenticate, may be set to :need, :want or :none (defaults to :none)
  • :output-buffer-size - (default 32768)
  • :input-buffer-size - (default 8192)
  • :request-header-size - (default 8192)
  • :response-header-size - (default 8192)
  • :send-server-version? - (default true)
  • :send-date-header? - (default false)
  • :header-cache-size - (default 512)
  • :websocket-handler - a handler function that will receive a RING request map with the following keys added:

    • :in: core.async chan that receives data sent by the client
    • :out: core async chan you can use to send data to client
    • :ctrl: core.async chan that received control messages such as: [::error e], [::close code reason]