akkadotnet / akka.net

Canonical actor model implementation for .NET with local + distributed actors in C# and F#.
http://getakka.net
Other
4.73k stars 1.04k forks source link

maximum-frame-size and maximum-payload-bytes are unclear when OversizedPayloadException is thrown #4903

Open andyfurnival opened 3 years ago

andyfurnival commented 3 years ago

When trying to track down why changes I was making had no effect, I think I may have spotted a configuration or message issue I've looked in Master branch of Akka.net, but I'm using 1.4.18 when this exception is thrown I'm running DotNet Core 3.1 on Linux

When I get this exception "Akka.Remote.OversizedPayloadException: Discarding oversized payload sent to..." is based on this line in Endpoint.cs https://github.com/akkadotnet/akka.net/blob/21762b90ac1d7db670487dda1368d84c61d693e5/src/core/Akka.Remote/Endpoint.cs#L1447

if (pdu.Length > Transport.MaximumPayloadBytes) { ... }

In HOCON I was using maximum-payload-bytes to change this, but I've noticed that this setting is only used in tests, and not in the Akka.Remote logic

When I followed this through, I found that MaximumPayloadBytes came from MaxFrameSize public override long MaximumPayloadBytes => Settings.MaxFrameSize; https://github.com/akkadotnet/akka.net/blob/21762b90ac1d7db670487dda1368d84c61d693e5/src/core/Akka.Remote/Transport/DotNetty/DotNettyTransport.cs#L154

TransportSettings maxFrameSize: ToNullableInt(config.GetByteSize("maximum-frame-size", null)) ?? 128000 https://github.com/akkadotnet/akka.net/blob/21762b90ac1d7db670487dda1368d84c61d693e5/src/core/Akka.Remote/Transport/DotNetty/DotNettyTransportSettings.cs#L89

and in HOCON it was remote.dot-netty.tcp.maximum-frame-size

The issue is maximum-payload-bytes seems to be only used for TestTransport, but the exception message leads you to this configuration, whereas maximum-frame-size is the right one for tuning based on that exception. I'm not sure if the Transport should be using maximum-frame-size or not, but I think it may help consolidate the configuration or make the error clearer

Aaronontheweb commented 3 years ago

Hi Andy,

That's correct - different transports have different ways of configuring this value, in theory, but the only effective one for the out of the box defaults in Akka.Remote is the dot-netty.tcp.maximum-frame-size setting. All transports have to have the notion of "largest acceptable payload" because we need some way of factoring in the network's hardware constraints (i.e. UDP can't send datagrams larger than ~64kb).

We'll try to make the error message clearer for when the DotNetty transport throws this - but users do use custom transports and that configuration input can be different for them too.