Properties

SDK-wide properties for configuring the Dapr Java SDK using environment variables and system properties

Properties

The Dapr Java SDK provides a set of global properties that control the behavior of the SDK. These properties can be configured using environment variables or system properties. System properties can be set using the -D flag when running your Java application.

These properties affect the entire SDK, including clients and runtime. They control aspects such as:

  • Sidecar connectivity (endpoints, ports)
  • Security settings (TLS, API tokens)
  • Performance tuning (timeouts, connection pools)
  • Protocol settings (gRPC, HTTP)
  • String encoding

Environment Variables

The following environment variables are available for configuring the Dapr Java SDK:

Sidecar Endpoints

When these variables are set, the client will automatically use them to connect to the Dapr sidecar.

Environment VariableDescriptionDefault
DAPR_GRPC_ENDPOINTThe gRPC endpoint for the Dapr sidecarlocalhost:50001
DAPR_HTTP_ENDPOINTThe HTTP endpoint for the Dapr sidecarlocalhost:3500
DAPR_GRPC_PORTThe gRPC port for the Dapr sidecar (legacy, DAPR_GRPC_ENDPOINT takes precedence)50001
DAPR_HTTP_PORTThe HTTP port for the Dapr sidecar (legacy, DAPR_HTTP_ENDPOINT takes precedence)3500

API Token

Environment VariableDescriptionDefault
DAPR_API_TOKENAPI token for authentication between app and Dapr sidecar. This is the same token used by the Dapr runtime for API authentication. For more details, see Dapr API token authentication and Environment variables reference.null

gRPC Configuration

TLS Settings

For secure gRPC communication, you can configure TLS settings using the following environment variables:

Environment VariableDescriptionDefault
DAPR_GRPC_TLS_INSECUREWhen set to “true”, enables insecure TLS mode which still uses TLS but doesn’t verify certificates. This uses InsecureTrustManagerFactory to trust all certificates. This should only be used for testing or in secure environments.false
DAPR_GRPC_TLS_CA_PATHPath to the CA certificate file. This is used for TLS connections to servers with self-signed certificates.null
DAPR_GRPC_TLS_CERT_PATHPath to the TLS certificate file for client authentication.null
DAPR_GRPC_TLS_KEY_PATHPath to the TLS private key file for client authentication.null

Keepalive Settings

Configure gRPC keepalive behavior using these environment variables:

Environment VariableDescriptionDefault
DAPR_GRPC_ENABLE_KEEP_ALIVEWhether to enable gRPC keepalivefalse
DAPR_GRPC_KEEP_ALIVE_TIME_SECONDSgRPC keepalive time in seconds10
DAPR_GRPC_KEEP_ALIVE_TIMEOUT_SECONDSgRPC keepalive timeout in seconds5
DAPR_GRPC_KEEP_ALIVE_WITHOUT_CALLSWhether to keep gRPC connection alive without callstrue

Inbound Message Settings

Configure gRPC inbound message settings using these environment variables:

Environment VariableDescriptionDefault
DAPR_GRPC_MAX_INBOUND_MESSAGE_SIZE_BYTESDapr’s maximum inbound message size for gRPC in bytes. This value sets the maximum size of a gRPC message that can be received by the application4194304
DAPR_GRPC_MAX_INBOUND_METADATA_SIZE_BYTESDapr’s maximum inbound metadata size for gRPC in bytes8192

HTTP Client Configuration

These properties control the behavior of the HTTP client used for communication with the Dapr sidecar:

Environment VariableDescriptionDefault
DAPR_HTTP_CLIENT_READ_TIMEOUT_SECONDSTimeout in seconds for HTTP client read operations. This is the maximum time to wait for a response from the Dapr sidecar.60
DAPR_HTTP_CLIENT_MAX_REQUESTSMaximum number of concurrent HTTP requests that can be executed. Above this limit, requests will queue in memory waiting for running calls to complete.1024
DAPR_HTTP_CLIENT_MAX_IDLE_CONNECTIONSMaximum number of idle connections in the HTTP connection pool. This is the maximum number of connections that can remain idle in the pool.128

API Configuration

These properties control the behavior of API calls made through the SDK:

Environment VariableDescriptionDefault
DAPR_API_MAX_RETRIESMaximum number of retries for retriable exceptions when making API calls to the Dapr sidecar0
DAPR_API_TIMEOUT_MILLISECONDSTimeout in milliseconds for API calls to the Dapr sidecar. A value of 0 means no timeout.0

String Encoding

Environment VariableDescriptionDefault
DAPR_STRING_CHARSETCharacter set used for string encoding/decoding in the SDK. Must be a valid Java charset name.UTF-8

System Properties

All environment variables can be set as system properties using the -D flag. Here is the complete list of available system properties:

System PropertyDescriptionDefault
dapr.sidecar.ipIP address for the Dapr sidecarlocalhost
dapr.http.portHTTP port for the Dapr sidecar3500
dapr.grpc.portgRPC port for the Dapr sidecar50001
dapr.grpc.tls.cert.pathPath to the gRPC TLS certificatenull
dapr.grpc.tls.key.pathPath to the gRPC TLS keynull
dapr.grpc.tls.ca.pathPath to the gRPC TLS CA certificatenull
dapr.grpc.tls.insecureWhether to use insecure TLS modefalse
dapr.grpc.endpointgRPC endpoint for remote sidecarnull
dapr.grpc.enable.keep.aliveWhether to enable gRPC keepalivefalse
dapr.grpc.keep.alive.time.secondsgRPC keepalive time in seconds10
dapr.grpc.keep.alive.timeout.secondsgRPC keepalive timeout in seconds5
dapr.grpc.keep.alive.without.callsWhether to keep gRPC connection alive without callstrue
dapr.http.endpointHTTP endpoint for remote sidecarnull
dapr.api.maxRetriesMaximum number of retries for API calls0
dapr.api.timeoutMillisecondsTimeout for API calls in milliseconds0
dapr.api.tokenAPI token for authenticationnull
dapr.string.charsetString encoding used in the SDKUTF-8
dapr.http.client.readTimeoutSecondsTimeout in seconds for HTTP client reads60
dapr.http.client.maxRequestsMaximum number of concurrent HTTP requests1024
dapr.http.client.maxIdleConnectionsMaximum number of idle HTTP connections128

Property Resolution Order

Properties are resolved in the following order:

  1. Override values (if provided when creating a Properties instance)
  2. System properties (set via -D)
  3. Environment variables
  4. Default values

The SDK checks each source in order. If a value is invalid for the property type (e.g., non-numeric for a numeric property), the SDK will log a warning and try the next source. For example:

# Invalid boolean value - will be ignored
java -Ddapr.grpc.enable.keep.alive=not-a-boolean -jar myapp.jar

# Valid boolean value - will be used
export DAPR_GRPC_ENABLE_KEEP_ALIVE=false

In this case, the environment variable is used because the system property value is invalid. However, if both values are valid, the system property takes precedence:

# Valid boolean value - will be used
java -Ddapr.grpc.enable.keep.alive=true -jar myapp.jar

# Valid boolean value - will be ignored
export DAPR_GRPC_ENABLE_KEEP_ALIVE=false

Override values can be set using the DaprClientBuilder in two ways:

  1. Using individual property overrides (recommended for most cases):
import io.dapr.config.Properties;

// Set a single property override
DaprClient client = new DaprClientBuilder()
    .withPropertyOverride(Properties.GRPC_ENABLE_KEEP_ALIVE, "true")
    .build();

// Or set multiple property overrides
DaprClient client = new DaprClientBuilder()
    .withPropertyOverride(Properties.GRPC_ENABLE_KEEP_ALIVE, "true")
    .withPropertyOverride(Properties.HTTP_CLIENT_READ_TIMEOUT_SECONDS, "120")
    .build();
  1. Using a Properties instance (useful when you have many properties to set at once):
// Create a map of property overrides
Map<String, String> overrides = new HashMap<>();
overrides.put("dapr.grpc.enable.keep.alive", "true");
overrides.put("dapr.http.client.readTimeoutSeconds", "120");

// Create a Properties instance with overrides
Properties properties = new Properties(overrides);

// Use these properties when creating a client
DaprClient client = new DaprClientBuilder()
    .withProperties(properties)
    .build();

For most use cases, you’ll use system properties or environment variables. Override values are primarily used when you need different property values for different instances of the SDK in the same application.

Proxy Configuration

You can configure proxy settings for your Java application using system properties. These are standard Java system properties that are part of Java’s networking layer (java.net package), not specific to Dapr. They are used by Java’s networking stack, including the HTTP client that Dapr’s SDK uses.

For detailed information about Java’s proxy configuration, including all available properties and their usage, see the Java Networking Properties documentation.

For example, here’s how to configure a proxy:

# Configure HTTP proxy - replace with your actual proxy server details
java -Dhttp.proxyHost=your-proxy-server.com -Dhttp.proxyPort=8080 -jar myapp.jar

# Configure HTTPS proxy - replace with your actual proxy server details
java -Dhttps.proxyHost=your-proxy-server.com -Dhttps.proxyPort=8443 -jar myapp.jar

Replace your-proxy-server.com with your actual proxy server hostname or IP address, and adjust the port numbers to match your proxy server configuration.

These proxy settings will affect all HTTP/HTTPS connections made by your Java application, including connections to the Dapr sidecar.