You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have some RPC client code that calls the RPC call uploadAttachmentWithMetadata. If the attachment already exists, I catch the DuplicateAttachmentException and just return the hash. Here is the Scala code that does that:
def addAttachment(name: String, path: Path): Either[String, SecureHash] = {
cordaConn.rpc.flatMap { rpc =>
Try {
val in = new FileInputStream(path.toFile)
rpc.uploadAttachmentWithMetadata(in, "app", name)
} match {
case Success(hash) =>
Right(hash)
case Failure(e) if e.isInstanceOf[CordaRuntimeException] &&
e.asInstanceOf[CordaRuntimeException].getOriginalExceptionClassName == "net.corda.nodeapi.exceptions.DuplicateAttachmentException" =>
val ce = e.asInstanceOf[CordaRuntimeException]
Right(SecureHash.parse(ce.getOriginalMessage))
case Failure(e) =>
Left(e.getMessage)
}
}
}
When NOT using the new graceful reconnect feature, this works fine (as it did in 4.2). However, if I use the graceful reconnect feature when connecting to RPC, the DuplicateAttachmentException is never caught and causes the RPC connection to drop. The log then shows repeated attempts to reconnect but is never successful.
This is how we connect without graceful reconnect:
new CordaRPCClient(url).start(user, password)
This is how we connect with graceful reconnect:
new CordaRPCClient(url).start(user, password, new GracefulReconnect(
() => {
log.warn(s"Disconnected from Corda node, it either went down or network connection was lost")
onDown(new IllegalStateException("Corda server disconnected"))
},
() => {
log.warn(s"Corda node reconnected after disconnection")
onUp()
},
-1
))
The text was updated successfully, but these errors were encountered:
I have some RPC client code that calls the RPC call uploadAttachmentWithMetadata. If the attachment already exists, I catch the DuplicateAttachmentException and just return the hash. Here is the Scala code that does that:
When NOT using the new graceful reconnect feature, this works fine (as it did in 4.2). However, if I use the graceful reconnect feature when connecting to RPC, the DuplicateAttachmentException is never caught and causes the RPC connection to drop. The log then shows repeated attempts to reconnect but is never successful.
This is how we connect without graceful reconnect:
This is how we connect with graceful reconnect:
The text was updated successfully, but these errors were encountered: