Akka Remoting Akka.Hosting Extensions
October 26, 2025 ยท View on GitHub
WithRemoting() Method
An extension method to add Akka.Remote support to the ActorSystem.
public static AkkaConfigurationBuilder WithRemoting(
this AkkaConfigurationBuilder builder,
string hostname = null,
int? port = null,
string publicHostname = null,
int? publicPort = null);
Parameters
-
hostnamestringOptional. The hostname to bind Akka.Remote upon.
Default:
IPAddress.Anyor "0.0.0.0" -
portint?Optional. The port to bind Akka.Remote upon.
Default: 2552
-
publicHostnamestringOptional. If using hostname aliasing, this is the host we will advertise.
Default: Fallback to
hostname -
publicPortint?Optional. If using port aliasing, this is the port we will advertise.
Default: Fallback to
port
Example
using var host = new HostBuilder()
.ConfigureServices((context, services) =>
{
services.AddAkka("remotingDemo", (builder, provider) =>
{
builder.WithRemoting("127.0.0.1", 4053);
});
}).Build();
await host.RunAsync();
SSL/TLS Configuration
Akka.Remote supports SSL/TLS encryption for secure communication between actor systems. Starting with Akka.NET v1.5.55, you can provide custom certificate validation callbacks using the CertificateValidation helper class.
using System.Security.Cryptography.X509Certificates;
using Akka.Remote.Transport.DotNetty;
var certificate = new X509Certificate2("/path/to/certificate.pfx", "certificate-password");
using var host = new HostBuilder()
.ConfigureServices((context, services) =>
{
services.AddAkka("secureSystem", (builder, provider) =>
{
builder.WithRemoting(options =>
{
options.HostName = "127.0.0.1";
options.Port = 4053;
options.EnableSsl = true;
options.Ssl.X509Certificate = certificate;
// Use built-in validators for common scenarios
options.Ssl.CustomValidator = CertificateValidation.Combine(
CertificateValidation.ValidateChain(),
CertificateValidation.ValidateSubject("CN=*.mycompany.com")
);
});
});
}).Build();
await host.RunAsync();
Available CertificateValidation methods: ValidateChain(), ValidateHostname(), PinnedCertificate(), ValidateSubject(), ValidateIssuer(), and Combine().