You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "mdedetrich (via GitHub)" <gi...@apache.org> on 2023/08/08 09:38:01 UTC

[GitHub] [incubator-pekko] mdedetrich commented on a diff in pull request #549: =sbt Do retry connection in Player.

mdedetrich commented on code in PR #549:
URL: https://github.com/apache/incubator-pekko/pull/549#discussion_r1286869433


##########
multi-node-testkit/src/main/scala/org/apache/pekko/remote/testconductor/Player.scala:
##########
@@ -338,21 +340,36 @@ private[pekko] class PlayerHandler(
 
   import ClientFSM._
 
-  val connectionRef: AtomicReference[RemoteConnection] = new AtomicReference[RemoteConnection](reconnect())
+  val connectionRef: AtomicReference[RemoteConnection] = new AtomicReference[RemoteConnection]()
 
   var nextAttempt: Deadline = _
 
+  tryConnectToController()
+
   @nowarn("msg=deprecated")
   override def exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable): Unit = {
     log.error("channel {} exception {}", ctx.channel(), cause)
     cause match {
       case _: ConnectException if reconnects > 0 =>
         reconnects -= 1
-        scheduler.scheduleOnce(nextAttempt.timeLeft)(connectionRef.set(reconnect()))
       case e => fsm ! ConnectionFailure(e.getMessage)
     }
   }
 
+  private def tryConnectToController(): Unit = {
+    Try(reconnect()) match {
+      case Success(r) => connectionRef.set(r)
+      case Failure(ex) =>

Review Comment:
   Is it worth it to use exponential backoff here or is that excessive?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org