ReplicaTransport
Last updated
Last updated
In the context of the Internet Computer blockchain, a Replica refers to the Internet Computer protocol processes running on a node.
To be able to connect remotely to the Internet Computer Canister IC4J implements ReplicaTransport interface over different Java HTTP Client libraries. Developers can choose specific implementations based on their Java application use cases.
interface currently supports 4 Internet Computer functions.
Calls in interface are asynchronous and return the response type.
The Apache HTTP 5 library is a robust, stable Java implementation of the HTTP protocol. It allows developers to define advanced features like connection pooling.
For advanced use cases, for example, to create Java server type applications handling a large number of clients and canisters, additional parameters can be defined.
url
Canister URL
maxTotal
Maximum total connections
maxPerRoute
Maximum connections per route
connectionTimeToLive
Time to live for connection in seconds
timeout
Connection timeout in seconds
For Android development it is recommended to use the OkHttp Client Implementation.
OkHttp is an efficient HTTP & HTTP/2 client for Android and Java applications.
If needed, the Connection Timeout can be explicitly defined :
From Java version 11 and higher, Oracle significantly improved functionality of Java default HTTP Client.
To make core libraries compatible with Java version 1.8, it is recommended that this version of transport is explicitly imported in the Graven or Maven build script.
If needed the connection timeout can be defined explicitly.
The simplest way to create is to use to create the Method with the IC URL String as a parameter.
For even more complex scenarios ReplicaTransport can be created with the explicitly defined Apache HTTP Client connection manager .
Use to create the Method with the IC URL String as a parameter to create OkHttp ReplicaTransport
Use to create the Method with the IC URL String as a parameter to create Java 11 ReplicaTransport