corda / net.corda.client.rpc / CordaRPCClient

CordaRPCClient

@ThreadSafe class CordaRPCClient : Closeable, ArtemisMessagingComponent

An RPC client connects to the specified server and allows you to make calls to the server that perform various useful tasks. See the documentation for proxy or review the docsite to learn more about how this API works.

Parameters

host - The hostname and messaging port of the node.

config - If specified, the SSL configuration to use. If not specified, SSL will be disabled and the node will only be authenticated on non-SSL RPC port, the RPC traffic with not be encrypted when SSL is disabled.

Constructors

<init> CordaRPCClient(host: HostAndPort, config: SSLConfiguration? = null, serviceConfigurationOverride: ServerLocator.() -> Unit = null)

An RPC client connects to the specified server and allows you to make calls to the server that perform various useful tasks. See the documentation for proxy or review the docsite to learn more about how this API works.

Properties

config val config: SSLConfiguration?
host val host: HostAndPort
serviceConfigurationOverride val serviceConfigurationOverride: ServerLocator.() -> Unit

Functions

close fun close(): Unit

Shuts down the client and lets the server know it can free the used resources (in a nice way).

proxy fun proxy(timeout: Duration? = null, minVersion: Int = 0): CordaRPCOps

Returns a fresh proxy that lets you invoke RPCs on the server. Calls on it block, and if the server throws an exception then it will be rethrown on the client. Proxies are thread safe but only one RPC can be in flight at once. If you'd like to perform multiple RPCs in parallel, use this function multiple times to get multiple proxies.

start fun start(username: String, password: String): CordaRPCClient

Opens the connection to the server with the given username and password, then returns itself. Registers a JVM shutdown hook to cleanly disconnect.

use fun <T> use(username: String, password: String, block: CordaRPCOps.() -> T): T

A convenience function that opens a connection with the given credentials, executes the given code block with all available RPCs in scope and shuts down the RPC connection again. It's meant for quick prototyping and demos. For more control you probably want to control the lifecycle of the client and proxies independently, as well as configuring a timeout and other such features via the proxy method.

Companion Object Properties

log val log: Logger