-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Akka.Remote: ensure RemoteActorRef are serialized with correct Address when using multiple transports
#7393
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
Changes from all commits
0d4a946
f5a437b
13f91b5
0cfcbde
9cac419
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1043,6 +1043,7 @@ public EndpointWriter( | |
| Inbound = handleOrActive != null; | ||
| _ackDeadline = NewAckDeadline(); | ||
| _handle = handleOrActive; | ||
| _transportInformation = new Information(localAddress, Context.System); | ||
| _remoteMetrics = RemoteMetricsExtension.Create(Context.System.AsInstanceOf<ExtendedActorSystem>()); | ||
|
|
||
| if (_handle == null) | ||
|
|
@@ -1056,6 +1057,7 @@ public EndpointWriter( | |
| } | ||
|
|
||
| private readonly ILoggingAdapter _log = Context.GetLogger(); | ||
| private readonly Information _transportInformation; | ||
| private readonly int? _refuseUid; | ||
| private readonly AkkaPduCodec _codec; | ||
| private readonly IActorRef _reliableDeliverySupervisor; | ||
|
|
@@ -1357,7 +1359,7 @@ private SerializedMessage SerializeMessage(object msg) | |
| { | ||
| throw new EndpointException("Internal error: No handle was present during serialization of outbound message."); | ||
| } | ||
| return MessageSerializer.Serialize(_system, _handle.LocalAddress, msg); | ||
| return MessageSerializer.Serialize(_system, _transportInformation, msg); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is part of the real fix - make sure we're always setting the current transport information to our transport before we perform outbound serialization. That way, any messages included inside the payloads get serialized onto the correct transport when we have multiple running. |
||
| } | ||
|
|
||
| private int _writeCount = 0; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,8 @@ internal static class MessageSerializer | |
| /// <param name="system">The system.</param> | ||
| /// <param name="messageProtocol">The message protocol.</param> | ||
| /// <returns>System.Object.</returns> | ||
| public static object Deserialize(ExtendedActorSystem system, SerializedMessage messageProtocol) | ||
| public static object Deserialize(ExtendedActorSystem system, | ||
| SerializedMessage messageProtocol) | ||
| { | ||
| return system.Serialization.Deserialize( | ||
| messageProtocol.Message.ToByteArray(), | ||
|
|
@@ -39,19 +40,18 @@ public static object Deserialize(ExtendedActorSystem system, SerializedMessage m | |
| /// Serializes the specified message. | ||
| /// </summary> | ||
| /// <param name="system">The system.</param> | ||
| /// <param name="address">TBD</param> | ||
| /// <param name="transportInformation">The address for the current transport</param> | ||
| /// <param name="message">The message.</param> | ||
| /// <returns>SerializedMessage.</returns> | ||
| public static SerializedMessage Serialize(ExtendedActorSystem system, Address address, object message) | ||
| public static SerializedMessage Serialize(ExtendedActorSystem system, Information transportInformation, | ||
| object message) | ||
| { | ||
| var serializer = system.Serialization.FindSerializerFor(message); | ||
|
|
||
| var oldInfo = Akka.Serialization.Serialization.CurrentTransportInformation; | ||
| try | ||
| { | ||
| if (oldInfo == null) | ||
| Akka.Serialization.Serialization.CurrentTransportInformation = | ||
| system.Provider.SerializationInformation; | ||
| Akka.Serialization.Serialization.CurrentTransportInformation = transportInformation; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The other part of the real fix - make sure we explicitly set the |
||
|
|
||
| var serializedMsg = new SerializedMessage | ||
| { | ||
|
|
@@ -81,4 +81,4 @@ public static SerializedMessage Serialize(ExtendedActorSystem system, Address ad | |
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently fails here - the
IActorRefreturned to theResolveOnemethod belongs to transport 1 rather than transport 2.