2019-05-01 08:12:09 +01:00
# Classic Remoting (Deprecated)
@@@ warning
2023-01-18 08:13:01 +01:00
Classic remoting has been deprecated. Please use @ref [Artery ](remoting-artery.md ) instead.
2019-05-01 08:12:09 +01:00
@@@
2011-12-15 18:05:24 +01:00
2019-04-29 13:18:03 +02:00
@@@ note
Remoting is the mechanism by which Actors on different nodes talk to each
other internally.
2023-01-20 09:40:34 +00:00
When building a Pekko application, you would usually not use the Remoting concepts
2019-04-29 13:18:03 +02:00
directly, but instead use the more high-level
2023-01-18 08:13:01 +01:00
@ref [Pekko Cluster ](index-cluster.md ) utilities or technology-agnostic protocols
2019-04-29 13:18:03 +02:00
such as [HTTP ](https://doc.akka.io/docs/akka-http/current/ ),
2019-05-31 16:17:02 +02:00
[gRPC ](https://doc.akka.io/docs/akka-grpc/current/ ) etc.
2019-04-29 13:18:03 +02:00
@@@
2019-11-05 20:06:32 +01:00
## Module info
2018-04-11 13:34:13 +02:00
2023-01-18 08:13:01 +01:00
To use Pekko Remoting, you must add the following dependency in your project:
2011-12-15 21:16:19 +01:00
2018-05-07 08:31:09 +01:00
@@dependency [sbt,Maven,Gradle] {
2023-01-05 11:10:50 +01:00
bomGroup=org.apache.pekko bomArtifact=pekko-bom_$scala.binary.version$ bomVersionSymbols=PekkoVersion
2022-12-02 14:49:16 +01:00
symbol1=PekkoVersion
2022-12-02 04:53:48 -08:00
value1="$pekko.version$"
2022-12-03 14:18:18 +01:00
group=org.apache.pekko
2023-01-05 11:10:50 +01:00
artifact=pekko-remote_$scala.binary.version$
2022-12-02 14:49:16 +01:00
version=PekkoVersion
2018-05-07 08:31:09 +01:00
}
2011-12-15 21:16:19 +01:00
2023-01-05 11:10:50 +01:00
@@project -info{ projectId="remote" }
2019-11-05 20:06:32 +01:00
2019-05-29 09:50:28 +01:00
Classic remoting depends on Netty. This needs to be explicitly added as a dependency so that users
not using classic remoting do not have to have Netty on the classpath:
@@dependency [sbt,Maven,Gradle] {
group=io.netty
artifact=netty
version=$netty_version$
}
2018-05-15 18:44:33 +09:00
## Configuration
2023-01-18 08:13:01 +01:00
To enable classic remoting in your Pekko project you should, at a minimum, add the following changes
2017-05-10 16:20:38 +02:00
to your `application.conf` file:
2011-12-15 18:05:24 +01:00
2017-05-10 16:20:38 +02:00
```
2022-12-02 04:53:48 -08:00
pekko {
2017-05-10 16:20:38 +02:00
actor {
2019-10-23 13:37:49 -04:00
# provider=remote is possible, but prefer cluster
provider = cluster
2011-12-15 18:05:24 +01:00
}
2019-05-02 19:20:02 +01:00
remote.artery.enabled = false
remote.classic {
2022-12-02 04:53:48 -08:00
enabled-transports = ["pekko.remote.classic.netty.tcp"]
2017-05-10 16:20:38 +02:00
netty.tcp {
hostname = "127.0.0.1"
port = 2552
}
}
}
```
2011-12-15 18:05:24 +01:00
2020-03-27 01:37:44 -07:00
As you can see in the example above there are four things you need to add to get started:
2011-12-23 10:25:05 +01:00
2023-01-18 08:13:01 +01:00
* Change provider from `local` . We recommend using @ref: [Pekko Cluster ](cluster-usage.md ) over using remoting directly.
2019-05-02 19:20:02 +01:00
* Disable artery remoting. Artery is the default remoting implementation since `2.6.0`
2017-05-10 16:20:38 +02:00
* Add host name - the machine you want to run the actor system on; this host
name is exactly what is passed to remote systems in order to identify this
system and consequently used for connecting back to this system if need be,
hence set it to a reachable IP address or resolvable name in case you want to
communicate across the network.
* Add port number - the port the actor system should listen on, set to 0 to have it chosen automatically
@@@ note
The port number needs to be unique for each actor system on the same machine even if the actor
systems have different names. This is because each actor system has its own networking subsystem
listening for connections and handling messages as not to interfere with other actor systems.
2011-12-23 10:25:05 +01:00
2017-05-10 16:20:38 +02:00
@@@
2012-08-16 17:00:06 +02:00
2011-12-23 10:25:05 +01:00
The example above only illustrates the bare minimum of properties you have to add to enable remoting.
2019-10-01 15:29:12 +02:00
All settings are described in @ref: [Remote Configuration ](#remote-configuration ).
2012-10-05 11:56:59 -07:00
2018-05-15 18:44:33 +09:00
## Introduction
2023-01-18 08:13:01 +01:00
We recommend @ref: [Pekko Cluster ](cluster-usage.md ) over using remoting directly. As remoting is the
2018-05-15 18:44:33 +09:00
underlying module that allows for Cluster, it is still useful to understand details about it though.
2023-01-18 08:13:01 +01:00
For an introduction of remoting capabilities of Pekko please see @ref: [Location Transparency ](general/remoting.md ).
2018-05-15 18:44:33 +09:00
@@@ note
2023-01-18 08:13:01 +01:00
As explained in that chapter Pekko remoting is designed for communication in a
2018-05-15 18:44:33 +09:00
peer-to-peer fashion and it is not a good fit for client-server setups. In
2023-01-18 08:13:01 +01:00
particular Pekko Remoting does not work transparently with Network Address Translation,
2018-05-15 18:44:33 +09:00
Load Balancers, or in Docker containers. For symmetric communication in these situations
2023-01-18 08:13:01 +01:00
network and/or Pekko configuration will have to be changed as described in
[Pekko behind NAT or in a Docker container ](#remote-configuration-nat ).
2018-05-15 18:44:33 +09:00
@@@
Disable Java serialization by default, #22333 (#27285)
* akka.actor.allow-java-serialization = off
* Moved primitive (Long, Int, String, ByteString) serializers
from akka-remote to akka-actor since they had no dependency
and are useful also in local systems, e.g. persistence.
* e.g. needed for persistence-tck
* less allow-java-serialization=on in tests
* CborSerializable in Jackson/test module for ease of use
* JavaSerializable for Java serialization in tests, already in akka-testkit,
but misconfigured
* Made tests pass
* allow-java-serialization=on in akka-persistence
* allow-java-serialization=on in classic remoting tests
* JavaSerializable and CborSerializable in other remoting tests
* Added serialization for
* Boolean
* java.util.concurrent.TimeoutException, AskTimeoutException
* support for testing serialization with the inmem journal
* utility to verifySerialization, in SerializationTestKit
* remove AccountExampleWithCommandHandlersInState becuase not possible to serialize State when it's not static
* Effect() is factory in EventSourcedBehavior class
* test the account examples
* SharedLeveldbJournal.configToEnableJavaSerializationForTest
* support for exceptions from remote deployed child actors
* fallback to akka.remote.serialization.ThrowableNotSerializableException
if exception is not serializable when wrapped in system messages from
remote deployed child actors and Status.Failure messages
* it's implemented in `WrappedPayloadSupport.payloadBuilder`
* update reference documentation
* serialize-messages=off in most places, separate ticket for
improving or removing that feature
* migration guide, including description of rolling update
* fix 2.13 compiler error
* minor review feedback
2019-07-11 14:04:24 +02:00
You need to enable @ref: [serialization ](serialization.md ) for your actor messages.
@ref: [Serialization with Jackson ](serialization-jackson.md ) is a good choice in many cases and our
recommendation if you don't have other preference.
2017-05-10 16:20:38 +02:00
## Types of Remote Interaction
2011-12-23 10:25:05 +01:00
2023-01-18 08:13:01 +01:00
Pekko has two ways of using remoting:
2011-12-23 10:25:05 +01:00
2017-05-10 16:20:38 +02:00
* Lookup : used to look up an actor on a remote node with `actorSelection(path)`
* Creation : used to create an actor on a remote node with `actorOf(Props(...), actorName)`
2011-12-23 10:25:05 +01:00
2011-12-23 11:29:51 +01:00
In the next sections the two alternatives are described in detail.
2011-12-23 10:25:05 +01:00
2017-05-10 16:20:38 +02:00
## Looking up Remote Actors
2011-12-21 23:33:13 +01:00
2017-05-10 16:20:38 +02:00
`actorSelection(path)` will obtain an `ActorSelection` to an Actor on a remote node, e.g.:
2011-12-21 23:33:13 +01:00
2017-05-26 11:15:26 +02:00
Scala
: ```
2017-05-10 16:20:38 +02:00
val selection =
2023-01-18 08:13:01 +01:00
context.actorSelection("pekko.tcp://actorSystemName@10 .0.0.1:2552/user/actorName")
2017-05-10 16:20:38 +02:00
```
2011-12-21 23:33:13 +01:00
2017-05-26 11:15:26 +02:00
Java
: ```
ActorSelection selection =
2023-01-18 08:13:01 +01:00
context.actorSelection("pekko.tcp://app@10 .0.0.1:2552/user/serviceA/worker");
2017-05-26 11:15:26 +02:00
```
2017-05-10 16:20:38 +02:00
As you can see from the example above the following pattern is used to find an actor on a remote node:
2011-12-21 23:33:13 +01:00
2017-05-10 16:20:38 +02:00
```
2023-01-18 08:13:01 +01:00
pekko.< protocol > ://< actor system name > @< hostname > :< port > /< actor path >
2017-05-10 16:20:38 +02:00
```
2011-12-23 10:25:05 +01:00
2017-05-10 16:20:38 +02:00
Once you obtained a selection to the actor you can interact with it in the same way you would with a local actor, e.g.:
2011-12-23 10:25:05 +01:00
2017-05-26 11:15:26 +02:00
Scala
: ```
2017-05-10 16:20:38 +02:00
selection ! "Pretty awesome feature"
```
2013-03-26 18:17:50 +01:00
2017-05-26 11:15:26 +02:00
Java
: ```
selection.tell("Pretty awesome feature", getSelf());
```
2017-05-10 16:20:38 +02:00
To acquire an `ActorRef` for an `ActorSelection` you need to
send a message to the selection and use the `sender` reference of the reply from
the actor. There is a built-in `Identify` message that all Actors will understand
and automatically reply to with a `ActorIdentity` message containing the
2018-12-19 21:54:22 +08:00
`ActorRef` . This can also be done with the `resolveOne` method of
2017-05-26 11:15:26 +02:00
the `ActorSelection` , which returns a @scala [`Future` ]@java [`CompletionStage` ] of the matching
2017-05-10 16:20:38 +02:00
`ActorRef` .
2011-12-21 23:33:13 +01:00
2017-05-10 16:20:38 +02:00
@@@ note
2012-08-14 20:42:54 +02:00
2017-05-11 17:27:57 +02:00
For more details on how actor addresses and paths are formed and used, please refer to @ref: [Actor References, Paths and Addresses ](general/addressing.md ).
2011-12-26 18:39:42 +01:00
2017-05-10 16:20:38 +02:00
@@@
2016-05-24 10:21:03 +01:00
2017-05-10 16:20:38 +02:00
@@@ note
2016-05-24 10:21:03 +01:00
2017-05-10 16:20:38 +02:00
Message sends to actors that are actually in the sending actor system do not
get delivered via the remote actor ref provider. They're delivered directly,
by the local actor ref provider.
2016-05-24 10:21:03 +01:00
2017-05-10 16:20:38 +02:00
Aside from providing better performance, this also means that if the hostname
you configure remoting to listen as cannot actually be resolved from within
the very same actor system, such messages will (perhaps counterintuitively)
be delivered just fine.
@@@
## Creating Actors Remotely
2011-12-15 18:05:24 +01:00
2023-01-18 08:13:01 +01:00
If you want to use the creation functionality in Pekko remoting you have to further amend the
2017-05-10 16:20:38 +02:00
`application.conf` file in the following way (only showing deployment section):
```
2022-12-02 04:53:48 -08:00
pekko {
2017-05-10 16:20:38 +02:00
actor {
deployment {
/sampleActor {
2023-01-18 08:13:01 +01:00
remote = "pekko.tcp://sampleActorSystem@127 .0.0.1:2553"
2012-02-02 09:40:17 +01:00
}
2011-12-15 18:05:24 +01:00
}
2012-02-02 09:40:17 +01:00
}
2017-05-10 16:20:38 +02:00
}
```
2011-12-23 10:25:05 +01:00
2023-01-18 08:13:01 +01:00
The configuration above instructs Pekko to react when an actor with path `/sampleActor` is created, i.e.
2017-05-26 11:15:26 +02:00
using @scala [`system.actorOf(Props(...), "sampleActor")` ]@java [`system.actorOf(new Props(...), "sampleActor")` ]. This specific actor will not be directly instantiated,
2011-12-23 11:29:51 +01:00
but instead the remote daemon of the remote system will be asked to create the actor,
2017-05-10 16:20:38 +02:00
which in this sample corresponds to `sampleActorSystem@127.0.0.1:2553` .
2011-12-23 10:25:05 +01:00
2012-09-21 15:08:56 +02:00
Once you have configured the properties above you would do the following in code:
2011-12-23 10:25:05 +01:00
2017-05-26 11:15:26 +02:00
Scala
2022-12-02 10:49:40 +01:00
: @@snip [RemoteDeploymentDocSpec.scala ](/docs/src/test/scala/docs/remoting/RemoteDeploymentDocSpec.scala ) { #sample -actor }
2017-05-26 11:15:26 +02:00
Java
2022-12-02 10:49:40 +01:00
: @@snip [RemoteDeploymentDocTest.java ](/docs/src/test/java/jdocs/remoting/RemoteDeploymentDocTest.java ) { #sample -actor }
2011-12-23 10:25:05 +01:00
2017-05-10 16:20:38 +02:00
The actor class `SampleActor` has to be available to the runtimes using it, i.e. the classloader of the
2011-12-23 10:25:05 +01:00
actor systems has to have a JAR containing the class.
2011-12-15 18:05:24 +01:00
Disable Java serialization by default, #22333 (#27285)
* akka.actor.allow-java-serialization = off
* Moved primitive (Long, Int, String, ByteString) serializers
from akka-remote to akka-actor since they had no dependency
and are useful also in local systems, e.g. persistence.
* e.g. needed for persistence-tck
* less allow-java-serialization=on in tests
* CborSerializable in Jackson/test module for ease of use
* JavaSerializable for Java serialization in tests, already in akka-testkit,
but misconfigured
* Made tests pass
* allow-java-serialization=on in akka-persistence
* allow-java-serialization=on in classic remoting tests
* JavaSerializable and CborSerializable in other remoting tests
* Added serialization for
* Boolean
* java.util.concurrent.TimeoutException, AskTimeoutException
* support for testing serialization with the inmem journal
* utility to verifySerialization, in SerializationTestKit
* remove AccountExampleWithCommandHandlersInState becuase not possible to serialize State when it's not static
* Effect() is factory in EventSourcedBehavior class
* test the account examples
* SharedLeveldbJournal.configToEnableJavaSerializationForTest
* support for exceptions from remote deployed child actors
* fallback to akka.remote.serialization.ThrowableNotSerializableException
if exception is not serializable when wrapped in system messages from
remote deployed child actors and Status.Failure messages
* it's implemented in `WrappedPayloadSupport.payloadBuilder`
* update reference documentation
* serialize-messages=off in most places, separate ticket for
improving or removing that feature
* migration guide, including description of rolling update
* fix 2.13 compiler error
* minor review feedback
2019-07-11 14:04:24 +02:00
When using remote deployment of actors you must ensure that all parameters of the `Props` can
be @ref: [serialized ](serialization.md ).
2017-05-10 16:20:38 +02:00
@@@ note
In order to ensure serializability of `Props` when passing constructor
2017-05-26 11:15:26 +02:00
arguments to the actor being created, do not make the factory @scala [an]@java [a non-static] inner class:
2017-05-10 16:20:38 +02:00
this will inherently capture a reference to its enclosing object, which in
2017-05-26 11:15:26 +02:00
most cases is not serializable. It is best to @scala [create a factory method in the
companion object of the actor’ s class]@java [make a static
inner class which implements `Creator<T extends Actor>` ].
2017-05-10 16:20:38 +02:00
Serializability of all Props can be tested by setting the configuration item
2022-12-02 04:53:48 -08:00
`pekko.actor.serialize-creators=on` . Only Props whose `deploy` has
2017-05-10 16:20:38 +02:00
`LocalScope` are exempt from this check.
2012-06-04 23:10:03 +02:00
2017-05-10 16:20:38 +02:00
@@@
2012-06-04 23:10:03 +02:00
2017-05-10 16:20:38 +02:00
@@@ note
2013-05-29 16:13:10 +02:00
2017-05-26 11:15:26 +02:00
You can use asterisks as wildcard matches for the actor path sections, so you could specify:
2017-05-10 16:20:38 +02:00
`/*/sampleActor` and that would match all `sampleActor` on that level in the hierarchy.
You can also use wildcard in the last position to match all actors at a certain level:
`/someParent/*` . Non-wildcard matches always have higher priority to match than wildcards, so:
`/foo/bar` is considered **more specific** than `/foo/*` and only the highest priority match is used.
Please note that it **cannot** be used to partially match section, like this: `/foo*/bar` , `/f*o/bar` etc.
2012-11-28 10:56:08 +01:00
2017-05-10 16:20:38 +02:00
@@@
2012-11-28 10:56:08 +01:00
2017-05-10 16:20:38 +02:00
### Programmatic Remote Deployment
2011-12-15 21:16:19 +01:00
2012-02-02 09:40:17 +01:00
To allow dynamically deployed systems, it is also possible to include
2017-05-10 16:20:38 +02:00
deployment configuration in the `Props` which are used to create an
2012-02-02 09:40:17 +01:00
actor: this information is the equivalent of a deployment section from the
configuration file, and if both are given, the external configuration takes
precedence.
With these imports:
2017-05-26 11:15:26 +02:00
Scala
2022-12-02 10:49:40 +01:00
: @@snip [RemoteDeploymentDocSpec.scala ](/docs/src/test/scala/docs/remoting/RemoteDeploymentDocSpec.scala ) { #import }
2017-05-26 11:15:26 +02:00
Java
2022-12-02 10:49:40 +01:00
: @@snip [RemoteDeploymentDocTest.java ](/docs/src/test/java/jdocs/remoting/RemoteDeploymentDocTest.java ) { #import }
2012-02-02 09:40:17 +01:00
and a remote address like this:
2017-05-26 11:15:26 +02:00
Scala
2022-12-02 10:49:40 +01:00
: @@snip [RemoteDeploymentDocSpec.scala ](/docs/src/test/scala/docs/remoting/RemoteDeploymentDocSpec.scala ) { #make -address }
2017-05-26 11:15:26 +02:00
Java
2022-12-02 10:49:40 +01:00
: @@snip [RemoteDeploymentDocTest.java ](/docs/src/test/java/jdocs/remoting/RemoteDeploymentDocTest.java ) { #make -address }
2012-02-02 09:40:17 +01:00
you can advise the system to create a child on that remote node like so:
2017-05-26 11:15:26 +02:00
Scala
2022-12-02 10:49:40 +01:00
: @@snip [RemoteDeploymentDocSpec.scala ](/docs/src/test/scala/docs/remoting/RemoteDeploymentDocSpec.scala ) { #deploy }
2017-05-26 11:15:26 +02:00
Java
2022-12-02 10:49:40 +01:00
: @@snip [RemoteDeploymentDocTest.java ](/docs/src/test/java/jdocs/remoting/RemoteDeploymentDocTest.java ) { #deploy }
2011-12-15 21:16:19 +01:00
2020-06-18 15:48:28 +02:00
### Remote deployment allow list
2016-10-24 13:44:15 +02:00
2020-06-18 15:48:28 +02:00
As remote deployment can potentially be abused by both users and even attackers an allow list feature
2016-10-24 13:44:15 +02:00
is available to guard the ActorSystem from deploying unexpected actors. Please note that remote deployment
is *not* remote code loading, the Actors class to be deployed onto a remote system needs to be present on that
remote system. This still however may pose a security risk, and one may want to restrict remote deployment to
2020-06-18 15:48:28 +02:00
only a specific set of known actors by enabling the allow list feature.
2016-10-24 13:44:15 +02:00
2022-12-02 04:53:48 -08:00
To enable remote deployment allow list set the `pekko.remote.deployment.enable-allow-list` value to `on` .
2017-03-31 13:52:05 +03:00
The list of allowed classes has to be configured on the "remote" system, in other words on the system onto which
others will be attempting to remote deploy Actors. That system, locally, knows best which Actors it should or
2016-10-24 13:44:15 +02:00
should not allow others to remote deploy onto it. The full settings section may for example look like this:
2023-01-05 11:10:50 +01:00
@@snip [RemoteDeploymentAllowListSpec.scala ](/remote/src/test/scala/org/apache/pekko/remote/classic/RemoteDeploymentAllowListSpec.scala ) { #allow -list-config }
2016-10-24 13:44:15 +02:00
2020-06-18 15:48:28 +02:00
Actor classes not included in the allow list will not be allowed to be remote deployed onto this system.
2016-10-24 13:44:15 +02:00
2017-05-10 16:20:38 +02:00
## Lifecycle and Failure Recovery Model
2013-12-12 13:05:59 +01:00
2017-11-22 16:09:42 +01:00

2013-12-12 13:05:59 +01:00
2014-08-06 15:38:52 +07:00
Each link with a remote system can be in one of the four states as illustrated above. Before any communication
2017-05-10 16:20:38 +02:00
happens with a remote system at a given `Address` the state of the association is `Idle` . The first time a message
2013-12-12 13:05:59 +01:00
is attempted to be sent to the remote system or an inbound connection is accepted the state of the link transitions to
2017-05-10 16:20:38 +02:00
`Active` denoting that the two systems has messages to send or receive and no failures were encountered so far.
When a communication failure happens and the connection is lost between the two systems the link becomes `Gated` .
2013-12-12 13:05:59 +01:00
In this state the system will not attempt to connect to the remote host and all outbound messages will be dropped. The time
2022-12-02 04:53:48 -08:00
while the link is in the `Gated` state is controlled by the setting `pekko.remote.retry-gate-closed-for` :
2017-05-10 16:20:38 +02:00
after this time elapses the link state transitions to `Idle` again. `Gate` is one-sided in the
sense that whenever a successful *inbound* connection is accepted from a remote system during `Gate` it automatically
transitions to `Active` and communication resumes immediately.
2013-12-12 13:05:59 +01:00
In the face of communication failures that are unrecoverable because the state of the participating systems are inconsistent,
2017-05-10 16:20:38 +02:00
the remote system becomes `Quarantined` . Unlike `Gate` , quarantining is permanent and lasts until one of the systems
is restarted. After a restart communication can be resumed again and the link can become `Active` again.
2013-12-12 13:05:59 +01:00
2017-05-10 16:20:38 +02:00
## Watching Remote Actors
2013-04-15 09:26:51 +02:00
Watching a remote actor is not different than watching a local actor, as described in
2017-05-11 17:27:57 +02:00
@ref: [Lifecycle Monitoring aka DeathWatch ](actors.md#deathwatch ).
2013-04-15 09:26:51 +02:00
2017-05-10 16:20:38 +02:00
### Failure Detector
2013-04-15 09:26:51 +02:00
2019-09-18 11:01:59 -07:00
Please see:
2013-04-15 09:26:51 +02:00
2019-09-18 11:01:59 -07:00
* @ref: [Phi Accrual Failure Detector ](typed/failure-detector.md ) implementation for details
2019-10-01 15:29:12 +02:00
* @ref: [Using the Failure Detector ](#using-the-failure-detector ) below for usage
2013-04-15 09:26:51 +02:00
2019-09-18 11:01:59 -07:00
### Using the Failure Detector
2022-11-12 10:21:24 +01:00
Remoting uses the `org.apache.pekko.remote.PhiAccrualFailureDetector` failure detector by default, or you can provide your by
implementing the `org.apache.pekko.remote.FailureDetector` and configuring it:
2013-04-15 09:26:51 +02:00
2017-05-10 16:20:38 +02:00
```
2022-12-02 04:53:48 -08:00
pekko.remote.watch-failure-detector.implementation-class = "com.example.CustomFailureDetector"
2019-09-18 11:01:59 -07:00
```
2019-10-01 15:29:12 +02:00
In the @ref: [Remote Configuration ](#remote-configuration ) you may want to adjust these
2019-09-18 11:01:59 -07:00
depending on you environment:
2022-12-02 04:53:48 -08:00
* When a *phi* value is considered to be a failure `pekko.remote.watch-failure-detector.threshold`
* Margin of error for sudden abnormalities `pekko.remote.watch-failure-detector.acceptable-heartbeat-pause`
2019-09-18 11:01:59 -07:00
2017-05-10 16:20:38 +02:00
## Serialization
2011-12-15 18:05:24 +01:00
Disable Java serialization by default, #22333 (#27285)
* akka.actor.allow-java-serialization = off
* Moved primitive (Long, Int, String, ByteString) serializers
from akka-remote to akka-actor since they had no dependency
and are useful also in local systems, e.g. persistence.
* e.g. needed for persistence-tck
* less allow-java-serialization=on in tests
* CborSerializable in Jackson/test module for ease of use
* JavaSerializable for Java serialization in tests, already in akka-testkit,
but misconfigured
* Made tests pass
* allow-java-serialization=on in akka-persistence
* allow-java-serialization=on in classic remoting tests
* JavaSerializable and CborSerializable in other remoting tests
* Added serialization for
* Boolean
* java.util.concurrent.TimeoutException, AskTimeoutException
* support for testing serialization with the inmem journal
* utility to verifySerialization, in SerializationTestKit
* remove AccountExampleWithCommandHandlersInState becuase not possible to serialize State when it's not static
* Effect() is factory in EventSourcedBehavior class
* test the account examples
* SharedLeveldbJournal.configToEnableJavaSerializationForTest
* support for exceptions from remote deployed child actors
* fallback to akka.remote.serialization.ThrowableNotSerializableException
if exception is not serializable when wrapped in system messages from
remote deployed child actors and Status.Failure messages
* it's implemented in `WrappedPayloadSupport.payloadBuilder`
* update reference documentation
* serialize-messages=off in most places, separate ticket for
improving or removing that feature
* migration guide, including description of rolling update
* fix 2.13 compiler error
* minor review feedback
2019-07-11 14:04:24 +02:00
You need to enable @ref: [serialization ](serialization.md ) for your actor messages.
@ref: [Serialization with Jackson ](serialization-jackson.md ) is a good choice in many cases and our
recommendation if you don't have other preference.
2016-09-30 14:42:12 +02:00
2017-05-10 16:20:38 +02:00
## Routers with Remote Destinations
2011-12-15 18:05:24 +01:00
2017-05-10 16:20:38 +02:00
It is absolutely feasible to combine remoting with @ref: [Routing ](routing.md ).
2011-12-15 18:05:24 +01:00
2014-02-11 14:48:24 +01:00
A pool of remote deployed routees can be configured as:
2022-12-02 10:49:40 +01:00
@@snip [RouterDocSpec.scala ](/docs/src/test/scala/docs/routing/RouterDocSpec.scala ) { #config -remote-round-robin-pool }
2014-02-11 14:48:24 +01:00
2017-05-10 16:20:38 +02:00
This configuration setting will clone the actor defined in the `Props` of the `remotePool` 10
2014-02-11 14:48:24 +01:00
times and deploy it evenly distributed across the two given target nodes.
Disable Java serialization by default, #22333 (#27285)
* akka.actor.allow-java-serialization = off
* Moved primitive (Long, Int, String, ByteString) serializers
from akka-remote to akka-actor since they had no dependency
and are useful also in local systems, e.g. persistence.
* e.g. needed for persistence-tck
* less allow-java-serialization=on in tests
* CborSerializable in Jackson/test module for ease of use
* JavaSerializable for Java serialization in tests, already in akka-testkit,
but misconfigured
* Made tests pass
* allow-java-serialization=on in akka-persistence
* allow-java-serialization=on in classic remoting tests
* JavaSerializable and CborSerializable in other remoting tests
* Added serialization for
* Boolean
* java.util.concurrent.TimeoutException, AskTimeoutException
* support for testing serialization with the inmem journal
* utility to verifySerialization, in SerializationTestKit
* remove AccountExampleWithCommandHandlersInState becuase not possible to serialize State when it's not static
* Effect() is factory in EventSourcedBehavior class
* test the account examples
* SharedLeveldbJournal.configToEnableJavaSerializationForTest
* support for exceptions from remote deployed child actors
* fallback to akka.remote.serialization.ThrowableNotSerializableException
if exception is not serializable when wrapped in system messages from
remote deployed child actors and Status.Failure messages
* it's implemented in `WrappedPayloadSupport.payloadBuilder`
* update reference documentation
* serialize-messages=off in most places, separate ticket for
improving or removing that feature
* migration guide, including description of rolling update
* fix 2.13 compiler error
* minor review feedback
2019-07-11 14:04:24 +02:00
When using a pool of remote deployed routees you must ensure that all parameters of the `Props` can
be @ref: [serialized ](serialization.md ).
2014-02-11 14:48:24 +01:00
A group of remote actors can be configured as:
2022-12-02 10:49:40 +01:00
@@snip [RouterDocSpec.scala ](/docs/src/test/scala/docs/routing/RouterDocSpec.scala ) { #config -remote-round-robin-group }
2011-12-15 18:05:24 +01:00
2014-02-11 14:48:24 +01:00
This configuration setting will send messages to the defined remote actor paths.
It requires that you create the destination actors on the remote nodes with matching paths.
2017-03-31 13:52:05 +03:00
That is not done by the router.
2011-12-23 23:58:39 +01:00
2017-05-10 16:20:38 +02:00
### Remote Events
2012-02-20 15:14:23 +01:00
2023-01-18 08:13:01 +01:00
It is possible to listen to events that occur in Pekko Remote, and to subscribe/unsubscribe to these events
2018-05-15 08:11:03 +02:00
you register as listener to the below described types in on the `ActorSystem.eventStream` .
2017-05-10 16:20:38 +02:00
@@@ note
2012-02-20 15:14:23 +01:00
2017-05-10 16:20:38 +02:00
To subscribe to any remote event, subscribe to
`RemotingLifecycleEvent` . To subscribe to events related only to
the lifecycle of associations, subscribe to
2022-11-12 10:21:24 +01:00
`org.apache.pekko.remote.AssociationEvent` .
2013-02-10 16:04:59 -05:00
2017-05-10 16:20:38 +02:00
@@@
2013-01-23 11:38:20 +01:00
2017-05-10 16:20:38 +02:00
@@@ note
2013-02-10 16:04:59 -05:00
2017-05-10 16:20:38 +02:00
The use of term "Association" instead of "Connection" reflects that the
remoting subsystem may use connectionless transports, but an association
similar to transport layer connections is maintained between endpoints by
2023-01-18 08:13:01 +01:00
the Pekko protocol.
2017-05-10 16:20:38 +02:00
@@@
2012-02-20 15:14:23 +01:00
2012-08-17 12:25:31 +02:00
By default an event listener is registered which logs all of the events
described below. This default was chosen to help setting up a system, but it is
quite common to switch this logging off once that phase of the project is
finished.
2017-05-10 16:20:38 +02:00
@@@ note
2019-05-02 19:20:02 +01:00
In order to disable the logging, set
2022-12-02 04:53:48 -08:00
`pekko.remote.classic.log-remote-lifecycle-events = off` in your
2017-05-10 16:20:38 +02:00
`application.conf` .
2013-02-10 16:04:59 -05:00
2017-05-10 16:20:38 +02:00
@@@
2012-08-17 12:25:31 +02:00
2017-05-10 16:20:38 +02:00
To be notified when an association is over ("disconnected") listen to `DisassociatedEvent` which
2013-01-23 11:38:20 +01:00
holds the direction of the association (inbound or outbound) and the addresses of the involved parties.
2012-02-20 15:14:23 +01:00
2017-05-10 16:20:38 +02:00
To be notified when an association is successfully established ("connected") listen to `AssociatedEvent` which
2013-01-23 11:38:20 +01:00
holds the direction of the association (inbound or outbound) and the addresses of the involved parties.
2012-02-20 15:14:23 +01:00
2017-05-10 16:20:38 +02:00
To intercept errors directly related to associations, listen to `AssociationErrorEvent` which
2013-01-23 11:38:20 +01:00
holds the direction of the association (inbound or outbound), the addresses of the involved parties and the
2017-05-10 16:20:38 +02:00
`Throwable` cause.
2012-02-20 15:14:23 +01:00
2017-05-10 16:20:38 +02:00
To be notified when the remoting subsystem is ready to accept associations, listen to `RemotingListenEvent` which
2013-01-23 11:38:20 +01:00
contains the addresses the remoting listens on.
2011-12-23 23:58:39 +01:00
2017-05-10 16:20:38 +02:00
To be notified when the current system is quarantined by the remote system, listen to `ThisActorSystemQuarantinedEvent` ,
2015-12-06 20:14:44 -05:00
which includes the addresses of local and remote ActorSystems.
2017-05-10 16:20:38 +02:00
To be notified when the remoting subsystem has been shut down, listen to `RemotingShutdownEvent` .
2011-12-23 23:58:39 +01:00
2017-05-10 16:20:38 +02:00
To intercept generic remoting related errors, listen to `RemotingErrorEvent` which holds the `Throwable` cause.
2012-05-22 12:08:49 +02:00
2017-05-10 16:20:38 +02:00
## Remote Security
2017-02-16 14:09:04 +01:00
2023-01-18 08:13:01 +01:00
An `ActorSystem` should not be exposed via Pekko Remote over plain TCP to an untrusted network (e.g. Internet).
2017-02-16 14:09:04 +01:00
It should be protected by network security, such as a firewall. If that is not considered as enough protection
2017-05-11 17:27:57 +02:00
[TLS with mutual authentication ](#remote-tls ) should be enabled.
2012-10-04 16:50:49 -07:00
2023-01-18 08:13:01 +01:00
Best practice is that Pekko remoting nodes should only be accessible from the adjacent network. Note that if TLS is
2017-05-26 11:15:26 +02:00
enabled with mutual authentication there is still a risk that an attacker can gain access to a valid certificate by
compromising any node with certificates issued by the same internal PKI tree.
2023-01-18 08:13:01 +01:00
By default, @ref [Java serialization ](serialization.md#java-serialization ) is disabled in Pekko.
Disable Java serialization by default, #22333 (#27285)
* akka.actor.allow-java-serialization = off
* Moved primitive (Long, Int, String, ByteString) serializers
from akka-remote to akka-actor since they had no dependency
and are useful also in local systems, e.g. persistence.
* e.g. needed for persistence-tck
* less allow-java-serialization=on in tests
* CborSerializable in Jackson/test module for ease of use
* JavaSerializable for Java serialization in tests, already in akka-testkit,
but misconfigured
* Made tests pass
* allow-java-serialization=on in akka-persistence
* allow-java-serialization=on in classic remoting tests
* JavaSerializable and CborSerializable in other remoting tests
* Added serialization for
* Boolean
* java.util.concurrent.TimeoutException, AskTimeoutException
* support for testing serialization with the inmem journal
* utility to verifySerialization, in SerializationTestKit
* remove AccountExampleWithCommandHandlersInState becuase not possible to serialize State when it's not static
* Effect() is factory in EventSourcedBehavior class
* test the account examples
* SharedLeveldbJournal.configToEnableJavaSerializationForTest
* support for exceptions from remote deployed child actors
* fallback to akka.remote.serialization.ThrowableNotSerializableException
if exception is not serializable when wrapped in system messages from
remote deployed child actors and Status.Failure messages
* it's implemented in `WrappedPayloadSupport.payloadBuilder`
* update reference documentation
* serialize-messages=off in most places, separate ticket for
improving or removing that feature
* migration guide, including description of rolling update
* fix 2.13 compiler error
* minor review feedback
2019-07-11 14:04:24 +02:00
That is also security best-practice because of its multiple
2021-08-31 10:00:03 +03:00
[known attack surfaces ](https://community.microfocus.com/cyberres/fortify/f/fortify-discussions/317555/the-perils-of-java-deserialization ).
2012-05-22 12:08:49 +02:00
2017-05-11 17:27:57 +02:00
< a id = "remote-tls" > < / a >
2023-01-18 08:13:01 +01:00
### Configuring SSL/TLS for Pekko Remoting
2012-08-20 17:04:20 +02:00
2022-12-02 04:53:48 -08:00
SSL can be used as the remote transport by adding `pekko.remote.classic.netty.ssl` to the `enabled-transport` configuration section.
2017-05-10 16:20:38 +02:00
An example of setting up the default Netty based SSL driver as default:
2016-09-30 12:13:08 +02:00
2017-05-10 16:20:38 +02:00
```
2022-12-02 04:53:48 -08:00
pekko {
2019-05-02 19:20:02 +01:00
remote.classic {
2022-12-02 04:53:48 -08:00
enabled-transports = [pekko.remote.classic.netty.ssl]
2016-10-28 14:58:32 +02:00
}
2017-05-10 16:20:38 +02:00
}
```
2016-09-30 12:13:08 +02:00
2017-05-10 16:20:38 +02:00
Next the actual SSL/TLS parameters have to be configured:
2016-10-28 14:58:32 +02:00
2017-05-10 16:20:38 +02:00
```
2022-12-02 04:53:48 -08:00
pekko {
2019-05-02 19:20:02 +01:00
remote.classic {
2017-05-10 16:20:38 +02:00
netty.ssl {
hostname = "127.0.0.1"
port = "3553"
2017-04-24 11:34:59 +02:00
2017-05-10 16:20:38 +02:00
security {
key-store = "/example/path/to/mykeystore.jks"
trust-store = "/example/path/to/mytruststore.jks"
2017-03-31 13:52:05 +03:00
2018-02-16 10:04:45 +01:00
key-store-password = ${SSL_KEY_STORE_PASSWORD}
key-password = ${SSL_KEY_PASSWORD}
trust-store-password = ${SSL_TRUST_STORE_PASSWORD}
2017-03-31 13:52:05 +03:00
2017-05-10 16:20:38 +02:00
protocol = "TLSv1.2"
2017-03-31 13:52:05 +03:00
2017-05-10 16:20:38 +02:00
enabled-algorithms = [TLS_DHE_RSA_WITH_AES_128_GCM_SHA256]
2016-09-30 12:13:08 +02:00
}
}
}
2017-05-10 16:20:38 +02:00
}
```
2016-09-30 12:13:08 +02:00
2018-02-16 10:04:45 +01:00
Always use [substitution from environment variables ](https://github.com/lightbend/config#optional-system-or-env-variable-overrides )
for passwords. Don't define real passwords in config files.
2021-08-30 16:05:41 +03:00
According to [RFC 7525 ](https://www.rfc-editor.org/rfc/rfc7525.html ) the recommended algorithms to use with TLS 1.2 (as of writing this document) are:
2016-10-28 14:58:32 +02:00
2017-05-10 16:20:38 +02:00
* TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
* TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
* TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
2016-10-28 14:58:32 +02:00
You should always check the latest information about security and algorithm recommendations though before you configure your system.
2023-01-20 09:40:34 +00:00
Since a Pekko remoting is inherently @ref: [peer-to-peer ](general/remoting.md#symmetric-communication ) both the key-store as well as trust-store
2016-10-28 14:58:32 +02:00
need to be configured on each remoting node participating in the cluster.
2020-05-06 15:02:12 +02:00
The official [Java Secure Socket Extension documentation ](https://docs.oracle.com/javase/8/docs/technotes/guides/security/jsse/JSSERefGuide.html )
2017-05-10 16:20:38 +02:00
as well as the [Oracle documentation on creating KeyStore and TrustStores ](https://docs.oracle.com/cd/E19509-01/820-3503/6nf1il6er/index.html )
2016-10-28 14:58:32 +02:00
are both great resources to research when setting up security on the JVM. Please consult those resources when troubleshooting
and configuring SSL.
2023-01-18 08:13:01 +01:00
Since Pekko 2.5.0 mutual authentication between TLS peers is enabled by default.
2017-02-16 14:09:04 +01:00
2017-03-31 13:52:05 +03:00
Mutual authentication means that the the passive side (the TLS server side) of a connection will also request and verify
2017-02-16 14:09:04 +01:00
a certificate from the connecting peer. Without this mode only the client side is requesting and verifying certificates.
2023-01-18 08:13:01 +01:00
While Pekko is a peer-to-peer technology, each connection between nodes starts out from one side (the "client") towards
2017-02-16 14:09:04 +01:00
the other (the "server").
2017-02-15 08:51:36 +01:00
Note that if TLS is enabled with mutual authentication there is still a risk that an attacker can gain access to a valid certificate
by compromising any node with certificates issued by the same internal PKI tree.
2017-07-26 16:23:46 +02:00
See also a description of the settings in the @ref: [Remote Configuration ](remoting.md#remote-configuration ) section.
2017-05-10 16:20:38 +02:00
@@@ note
2013-03-26 18:17:50 +01:00
2017-05-10 16:20:38 +02:00
When using SHA1PRNG on Linux it's recommended specify `-Djava.security.egd=file:/dev/urandom` as argument
to the JVM to prevent blocking. It is NOT as secure because it reuses the seed.
2012-08-20 17:04:20 +02:00
2017-05-10 16:20:38 +02:00
@@@
2013-03-26 18:17:50 +01:00
2017-05-10 16:20:38 +02:00
### Untrusted Mode
2017-02-16 14:09:04 +01:00
As soon as an actor system can connect to another remotely, it may in principle
send any possible message to any actor contained within that remote system. One
2017-05-10 16:20:38 +02:00
example may be sending a `PoisonPill` to the system guardian, shutting
2017-02-16 14:09:04 +01:00
that system down. This is not always desired, and it can be disabled with the
2017-05-10 16:20:38 +02:00
following setting:
2017-02-16 14:09:04 +01:00
2017-05-10 16:20:38 +02:00
```
2022-12-02 04:53:48 -08:00
pekko.remote.classic.untrusted-mode = on
2017-05-10 16:20:38 +02:00
```
2017-02-16 14:09:04 +01:00
This disallows sending of system messages (actor life-cycle commands,
2017-05-10 16:20:38 +02:00
DeathWatch, etc.) and any message extending `PossiblyHarmful` to the
2017-02-16 14:09:04 +01:00
system on which this flag is set. Should a client send them nonetheless they
are dropped and logged (at DEBUG level in order to reduce the possibilities for
2017-05-10 16:20:38 +02:00
a denial of service attack). `PossiblyHarmful` covers the predefined
messages like `PoisonPill` and `Kill` , but it can also be added
2017-02-16 14:09:04 +01:00
as a marker trait to user-defined messages.
2017-05-10 16:20:38 +02:00
@@@ warning
2017-03-31 13:52:05 +03:00
2017-05-10 16:20:38 +02:00
Untrusted mode does not give full protection against attacks by itself.
It makes it slightly harder to perform malicious or unintended actions but
Disable Java serialization by default, #22333 (#27285)
* akka.actor.allow-java-serialization = off
* Moved primitive (Long, Int, String, ByteString) serializers
from akka-remote to akka-actor since they had no dependency
and are useful also in local systems, e.g. persistence.
* e.g. needed for persistence-tck
* less allow-java-serialization=on in tests
* CborSerializable in Jackson/test module for ease of use
* JavaSerializable for Java serialization in tests, already in akka-testkit,
but misconfigured
* Made tests pass
* allow-java-serialization=on in akka-persistence
* allow-java-serialization=on in classic remoting tests
* JavaSerializable and CborSerializable in other remoting tests
* Added serialization for
* Boolean
* java.util.concurrent.TimeoutException, AskTimeoutException
* support for testing serialization with the inmem journal
* utility to verifySerialization, in SerializationTestKit
* remove AccountExampleWithCommandHandlersInState becuase not possible to serialize State when it's not static
* Effect() is factory in EventSourcedBehavior class
* test the account examples
* SharedLeveldbJournal.configToEnableJavaSerializationForTest
* support for exceptions from remote deployed child actors
* fallback to akka.remote.serialization.ThrowableNotSerializableException
if exception is not serializable when wrapped in system messages from
remote deployed child actors and Status.Failure messages
* it's implemented in `WrappedPayloadSupport.payloadBuilder`
* update reference documentation
* serialize-messages=off in most places, separate ticket for
improving or removing that feature
* migration guide, including description of rolling update
* fix 2.13 compiler error
* minor review feedback
2019-07-11 14:04:24 +02:00
it should be noted that @ref: [Java serialization ](serialization.md#java-serialization )
should still not be enabled.
2017-05-10 16:20:38 +02:00
Additional protection can be achieved when running in an untrusted network by
Disable Java serialization by default, #22333 (#27285)
* akka.actor.allow-java-serialization = off
* Moved primitive (Long, Int, String, ByteString) serializers
from akka-remote to akka-actor since they had no dependency
and are useful also in local systems, e.g. persistence.
* e.g. needed for persistence-tck
* less allow-java-serialization=on in tests
* CborSerializable in Jackson/test module for ease of use
* JavaSerializable for Java serialization in tests, already in akka-testkit,
but misconfigured
* Made tests pass
* allow-java-serialization=on in akka-persistence
* allow-java-serialization=on in classic remoting tests
* JavaSerializable and CborSerializable in other remoting tests
* Added serialization for
* Boolean
* java.util.concurrent.TimeoutException, AskTimeoutException
* support for testing serialization with the inmem journal
* utility to verifySerialization, in SerializationTestKit
* remove AccountExampleWithCommandHandlersInState becuase not possible to serialize State when it's not static
* Effect() is factory in EventSourcedBehavior class
* test the account examples
* SharedLeveldbJournal.configToEnableJavaSerializationForTest
* support for exceptions from remote deployed child actors
* fallback to akka.remote.serialization.ThrowableNotSerializableException
if exception is not serializable when wrapped in system messages from
remote deployed child actors and Status.Failure messages
* it's implemented in `WrappedPayloadSupport.payloadBuilder`
* update reference documentation
* serialize-messages=off in most places, separate ticket for
improving or removing that feature
* migration guide, including description of rolling update
* fix 2.13 compiler error
* minor review feedback
2019-07-11 14:04:24 +02:00
network security (e.g. firewalls) and/or enabling @ref: [TLS with mutual authentication ](#remote-tls ).
2017-05-10 16:20:38 +02:00
@@@
2017-02-16 14:09:04 +01:00
Messages sent with actor selection are by default discarded in untrusted mode, but
permission to receive actor selection messages can be granted to specific actors
2017-05-10 16:20:38 +02:00
defined in configuration:
2017-02-16 14:09:04 +01:00
2017-05-10 16:20:38 +02:00
```
2022-12-02 04:53:48 -08:00
pekko.remote.classic.trusted-selection-paths = ["/user/receptionist", "/user/namingService"]
2017-05-10 16:20:38 +02:00
```
2017-02-16 14:09:04 +01:00
2017-05-10 16:20:38 +02:00
The actual message must still not be of type `PossiblyHarmful` .
2017-02-16 14:09:04 +01:00
In summary, the following operations are ignored by a system configured in
untrusted mode when incoming via the remoting layer:
2017-05-10 16:20:38 +02:00
* remote deployment (which also means no remote supervision)
* remote DeathWatch
* `system.stop()` , `PoisonPill` , `Kill`
* sending any message which extends from the `PossiblyHarmful` marker
interface, which includes `Terminated`
* messages sent with actor selection, unless destination defined in `trusted-selection-paths` .
2017-02-16 14:09:04 +01:00
2017-05-10 16:20:38 +02:00
@@@ note
2017-02-16 14:09:04 +01:00
2017-05-10 16:20:38 +02:00
Enabling the untrusted mode does not remove the capability of the client to
freely choose the target of its message sends, which means that messages not
prohibited by the above rules can be sent to any actor in the remote system.
It is good practice for a client-facing system to only contain a well-defined
set of entry point actors, which then forward requests (possibly after
performing validation) to another actor system containing the actual worker
actors. If messaging between these two server-side systems is done using
local `ActorRef` (they can be exchanged safely between actor systems
within the same JVM), you can restrict the messages on this interface by
marking them `PossiblyHarmful` so that a client cannot forge them.
2017-02-16 14:09:04 +01:00
2017-05-10 16:20:38 +02:00
@@@
2013-04-15 09:26:51 +02:00
2017-05-10 16:20:38 +02:00
## Remote Configuration
2013-04-15 09:26:51 +02:00
2023-01-18 08:13:01 +01:00
There are lots of configuration properties that are related to remoting in Pekko. We refer to the
@ref: [reference configuration ](general/configuration-reference.md#config-pekko-remote ) for more information.
2013-04-15 09:26:51 +02:00
2017-05-10 16:20:38 +02:00
@@@ note
2013-04-15 09:26:51 +02:00
2017-05-10 16:20:38 +02:00
Setting properties like the listening IP and port number programmatically is
best done by using something like the following:
2013-04-15 09:26:51 +02:00
2022-12-02 10:49:40 +01:00
@@snip [RemoteDeploymentDocTest.java ](/docs/src/test/java/jdocs/remoting/RemoteDeploymentDocTest.java ) { #programmatic }
2015-09-09 10:14:51 +02:00
2017-05-10 16:20:38 +02:00
@@@
2015-09-09 10:14:51 +02:00
2017-05-10 16:20:38 +02:00
< a id = "remote-configuration-nat" > < / a >
2023-01-18 08:13:01 +01:00
### Pekko behind NAT or in a Docker container
2015-09-09 10:14:51 +02:00
In setups involving Network Address Translation (NAT), Load Balancers or Docker
2023-01-18 08:13:01 +01:00
containers the hostname and port pair that Pekko binds to will be different than the "logical"
2015-09-09 10:14:51 +02:00
host name and port pair that is used to connect to the system from the outside. This requires
special configuration that sets both the logical and the bind pairs for remoting.
2019-05-02 19:20:02 +01:00
```
2022-12-02 04:53:48 -08:00
pekko.remote.classic.netty.tcp {
2017-05-10 16:20:38 +02:00
hostname = my.domain.com # external (logical) hostname
port = 8000 # external (logical) port
2015-09-09 10:14:51 +02:00
2017-05-10 16:20:38 +02:00
bind-hostname = local.address # internal (bind) hostname
bind-port = 2552 # internal (bind) port
}
```
2017-04-24 16:22:12 +02:00
Keep in mind that local.address will most likely be in one of private network ranges:
2017-05-10 16:20:38 +02:00
* *10.0.0.0 - 10.255.255.255* (network class A)
* *172.16.0.0 - 172.31.255.255* (network class B)
* *192.168.0.0 - 192.168.255.255* (network class C)
2017-04-24 16:22:12 +02:00
2021-08-30 16:05:41 +03:00
For further details see [RFC 1597 ](https://www.rfc-editor.org/rfc/rfc1597.html ) and [RFC 1918 ](https://www.rfc-editor.org/rfc/rfc1918.html ).