Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graceful reconnect feature of RPC causes exception to drop connection #5908

Closed
countfloyd opened this issue Jan 29, 2020 · 4 comments
Closed
Labels

Comments

@countfloyd
Copy link

countfloyd commented Jan 29, 2020

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
))
@countfloyd
Copy link
Author

This happens in version 4.3. Version 4.2 worked as expected. Attaching corda log.
corda_log.txt

@fowlerrr
Copy link
Contributor

Hi, do you also have a copy of the logs from the RPC client? Those logs look like RPC server/node logs

@countfloyd
Copy link
Author

Sure, here you go. Just so you know, I've submitted this bug on the enterprise support portal as well (SUP-1098)
client_log.txt

@davidrapacchiale
Copy link
Contributor

Thanks @countfloyd for this.

@fowlerrr , I have raised a bug in our OS Jira instance (https://r3-cev.atlassian.net/browse/CORDA-3572). Please reference that once you have a fix ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants