swift-distributed-actors
swift-distributed-actors copied to clipboard
SerializationError
I have encountered trouble receiving remote calls after successfully joining from the iOS to the macOS cluster.
13:52:04 error [sact://Boguś@127.0.0.1:7337[1m/system/receptionist[0;0m][OperationLogDistributedReceptionist.swift:861] Failed to pushOps: DistributedCluster.OpLogDistributedReceptionist.PushOps
// metadata:
// "actor/id": [$wellKnown: receptionist]
// "error": GenericRemoteCallError(message: "Remote call error of [SerializationError] type occurred")
// "receptionist/peer": [$wellKnown: receptionist]
I am running a sample project on the macOS cluster on 192.168.1.8:8228
. The same philosopher dining sample was copied to a simple iOS app with little modification:
final class DiningPhilosophers {
private var forks: [Fork] = []
private var philosophers: [Philosopher] = []
func run(for duration: Duration) async throws {
let system = await ClusterSystem("Boguś") { settings in
settings.bindPort = 7337
settings.remoteCall.codableErrorAllowance = .all
}
system.cluster.join(host: "192.168.1.8", port: 8228)
try await self.ensureCluster([system], within: .seconds(10))
let leftFork = Fork(name: "fork-6", actorSystem: system)
let rightFork = Fork(name: "fork-7", actorSystem: system)
let bogus = Philosopher(
name: "Boguś",
leftFork: leftFork,
rightFork: rightFork,
actorSystem: system
)
await system.receptionist.checkIn(bogus, with: .thinkers)
var thinkers: WeakActorDictionary<Philosopher> = [:]
for await philosopher in await system.receptionist.listing(of: .thinkers) {
print("Philosopher # \(philosopher.hashValue) exists!")
thinkers.insert(philosopher)
}
try system.park(atMost: duration)
}
private func ensureCluster(_ systems: [ClusterSystem], within: Duration) async throws {
let nodes = Set(systems.map(\.settings.bindNode))
try await withThrowingTaskGroup(of: Void.self) { group in
for system in systems {
group.addTask {
try await system.cluster.waitFor(nodes, .up, within: within)
}
}
// loop explicitly to propagagte any error that might have been thrown
for try await _ in group {}
}
}
}
How can I fix it?