Raghvendra Singh
Raghvendra Singh

Reputation: 1805

dropwizard jetty server request timeout

I have a webservice built on top of dropwizard. There is a request which is supposed to take a long time and the request client is supposed to wait for the server response. But what i am observing is that the request is being responded by the server even before the application can process it. Here is an output of curl

curl -vvv  --max-time 600 -H "Content-Type: application/json" -X POST -d '{"sourceId":0,"pastNMinutes":1440,"metricIds":[33570, 33571, 33572, 33573, 33574, 33575]}' http://localhost:30000/blitz-reader/metric-reader/reportedNodes
* Hostname was NOT found in DNS cache
*   Trying ::1...
* Connected to localhost (::1) port 30000 (#0)
> POST /blitz-reader/metric-reader/reportedNodes HTTP/1.1
> User-Agent: curl/7.37.1
> Host: localhost:30000
> Accept: */*
> Content-Type: application/json
> Content-Length: 89
> 
* upload completely sent off: 89 out of 89 bytes
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server

Below is the http part of the configuration yml

# HTTP-specific options.
http:

  # The port on which the HTTP server listens for service requests.
  port: ${blitzReaderPort}

  # The port on which the HTTP server listens for administrative requests.
  adminPort: ${blitzReaderAdminPort}

  # Maximum number of threads.
  maxThreads: 300

  # Minimum number of thread to keep alive.
  minThreads: 10

  # The type of connector to use. Other valid values are "nonblocking" or "legacy". In general, the
  # blocking connector should be used for low-latency services with short request durations. The
  # nonblocking connector should be used for services with long request durations or which
  # specifically take advantage of Jetty's continuation support.
  # If you need SSL support, you can either choose from "nonblocking+ssl" or "legacy+ssl".
  connectorType: blocking

  # The maximum amount of time a connection is allowed to be idle before being closed.
  maxIdleTime: 60s

  # The number of threads dedicated to accepting connections. If omitted, this defaults to the
  # number of logical CPUs on the current machine.
  #acceptorThreads: 3

  # The offset of the acceptor threads' priorities. Can be [-5...5], with -5 dropping the acceptor
  # threads to the lowest possible priority and with 5 raising them to the highest priority.
  acceptorThreadPriorityOffset: 0

  # The number of unaccepted requests to keep in the accept queue before refusing connections. If
  # set to -1 or omitted, the system default is used.
  acceptQueueSize: 100

  # The maximum number of buffers to keep in memory.
  maxBufferCount: 1024

  # The initial buffer size for reading requests.
  requestBufferSize: 32KB

  # The initial buffer size for reading request headers.
  requestHeaderBufferSize: 6KB

  # The initial buffer size for writing responses.
  responseBufferSize: 32KB

  # The initial buffer size for writing response headers.
  responseHeaderBufferSize: 6KB

  # Enables SO_REUSEADDR on the server socket.
  reuseAddress: true

  # Enables SO_LINGER on the server socket with the specified linger time.
  soLingerTime: 1s

  # The number of open connections at which the server transitions to a "low-resources" mode.
  lowResourcesConnectionThreshold: 25000

  # When in low-resources mode, the maximum amount of time a connection is allowed to be idle before
  # being closed. Overrides maxIdleTime.
  lowResourcesMaxIdleTime: 10s

  # If non-zero, the server will allow worker threads to finish processing requests after the server
  # socket has been closed for the given amount of time.
  shutdownGracePeriod: 2s

  # If true, the HTTP server will prefer X-Forwarded headers over their non-forwarded equivalents.
  useForwardedHeaders: true

  # If true, forces the HTTP connector to use off-heap, direct buffers.
  useDirectBuffers: true

  # The hostname of the interface to which the HTTP server socket wil be found. If omitted, the
  # socket will listen on all interfaces.
  # bindHost: app1.example.com

#  ssl:
#    keyStore: ./example.keystore
#    keyStorePassword: example
#
#    keyStoreType: JKS # (optional, JKS is default)

  # HTTP request log settings
  requestLog:
    # Settings for logging to stdout.
    console:
      # If true, write log statements to stdout.
      enabled: false

    # Settings for logging to a file.
    file:
      # If true, write log statements to a file.
      enabled: true

      # The file to which statements will be logged.
      currentLogFilename: ../logs/reader/requests.log

      #  When the log file rolls over, the file will be archived to example-2012-03-15.log.gz,
      # example.log will be truncated, and new statements written to it.
      archivedLogFilenamePattern: ../logs/reader/requests-%d.log.gz

      # The maximum number of log files to archive.
      archivedFileCount: 5

    # Settings for logging to syslog.
    syslog:

      # If true, write log statements to syslog.
      enabled: false

      # The hostname of the syslog server to which statements will be sent.
      # N.B.: If this is the local host, the local syslog instance will need to be configured to
      # listen on an inet socket, not just a Unix socket.
      host: localhost

      # The syslog facility to which statements will be sent.
      facility: local0

What is the parameter i can give to let the server wait and not respond with empty response?

Upvotes: 2

Views: 8553

Answers (2)

madmuffin
madmuffin

Reputation: 993

Since Dropwizard versions 0.7 and above (tested with current 0.9) the configuration was moved to another parameter:

server:
  applicationConnectors:
    - type: http
      ...
      idleTimeout: 60s

Taken from the documentation at https://dropwizard.github.io/dropwizard/0.9.1/docs/manual/configuration.html#http

Upvotes: 3

Raghvendra Singh
Raghvendra Singh

Reputation: 1805

I figured it out. It was this parameter

# HTTP-specific options.
http:

  # The maximum amount of time a connection is allowed to be idle before being closed.
  maxIdleTime: 60s

Increased that to a longer time and all was good.

Upvotes: 1

Related Questions