Open stdstring opened 1 year ago
For 0.0.0.0, you need to also set an "AdvertisedHost", so that remote systems know what to connect to. as you cannot remotely connect to 0.0.0.0.
I know about AdvertisedHost
property, but i can't use it because my server is situated inside the Docker container (and server doesn't know anything about Docker container address). Moreover, the same example on .NET (whiсh used protoactor.NET library) works correctly (when server has 0.0.0.0
address) without usage of AdvertisedHost
property.
If you look on server output (when server has 0.0.0.0
address), you can see, that server receives connect request from client (EndpointReader received connect request message=server_connection:{SystemId:"JgBn2wcP3TNW4HwP9Gm9vg" Address:"127.0.0.1:34444"}
). But after that server receives another connect request from itself (EndpointReader received connect request message=server_connection:{SystemId:"5UKtdU7DkjnAovWJ65fsvQ" Address:"[::]:23333"}
). It seems, that this is reason of this issue.
@rogeralsing
I made example with AdvertisedHost
as you advised me:
I have the following definition of server app:
package main
import (
"fmt"
console "github.com/asynkron/goconsole"
"github.com/asynkron/protoactor-go/actor"
"github.com/asynkron/protoactor-go/remote"
"os"
"protoActorRemote/messages"
)
const host = "0.0.0.0"
const port = 23333
const name = "ProtoactorProblemExample"
func main() {
system := actor.NewActorSystem()
config := remote.Configure(host, port, remote.WithAdvertisedHost("localhost:23333"))
remoter := remote.NewRemote(system, config)
remoter.Start()
props := actor.PropsFromFunc(func(context actor.Context) {
switch msg := context.Message().(type) {
case *actor.Started:
fmt.Printf("Started server with address \"%v\"\n", context.Self().Address)
case *actor.Stopping:
fmt.Printf("Stopping server with address \"%v\"\n", context.Self().Address)
case *actor.Stopped:
fmt.Printf("Stopped server with address \"%v\"\n", context.Self().Address)
case *actor.Restarting:
fmt.Printf("Restarting server with address \"%v\"\n", context.Self().Address)
case *messages.RequestTypeA:
fmt.Printf("RequestTypeA with data \"%v\" from client with address \"%v\" (server address = \"%v\")\n", msg.Data, context.Sender().Address, context.Self().Address)
context.Send(context.Sender(), &messages.ResponseTypeA{Data: msg.Data + ".resultA"})
default:
fmt.Printf("Other message %v\n", msg)
}
})
_, spawnError := system.Root.SpawnNamed(props, name)
if spawnError != nil {
fmt.Printf("Spawn error \"%v\"\n", spawnError)
os.Exit(-1)
}
fmt.Println("Server started")
_, _ = console.ReadLine()
}
When I start server first and after that - client, then I have the following output on server:
2023/03/23 16:44:29 INFO [REMOTE] Starting remote with address address="localhost:22333"
2023/03/23 16:44:29 INFO [REMOTE] Started Activator
Server started
2023/03/23 16:44:29 INFO [REMOTE] Started EndpointManager
2023/03/23 16:44:29 INFO [REMOTE] Starting Proto.Actor server address="localhost:22333"
Started server with address "localhost:22333"
2023/03/23 16:44:34 DEBUG [REMOTE] EndpointReader received connect request message=server_connection:{SystemId:"8Y7ty56Y37qEU5GgQLtUpn" Address:"127.0.0.1:34443"}
2023/03/23 16:44:34 DEBUG [REMOTE] EndpointSupervisor spawning EndpointWriter and EndpointWatcher address="127.0.0.1:22333"
2023/03/23 16:44:34 INFO [REMOTE] Started EndpointWriter. connecting address="127.0.0.1:22333"
2023/03/23 16:44:34 INFO [REMOTE] Started EndpointWatcher address="127.0.0.1:22333"
2023/03/23 16:44:34 DEBUG [REMOTE] EndpointReader received connect request message=server_connection:{SystemId:"Q2eebY9vXBwFkhUzS4ddWz" Address:"localhost:22333"}
2023/03/23 16:44:34 DEBUG [REMOTE] Received connect response fromAddress="127.0.0.1:22333"
2023/03/23 16:44:34 INFO [REMOTE] EndpointWriter connected address="127.0.0.1:22333" cost=3.7093ms
2023/03/23 16:44:35 INFO [REMOTE] EndpointReader failed to read error="rpc error: code = Canceled desc = context canceled"
2023/03/23 16:44:35 DEBUG [REMOTE] EndpointReader removed active endpoint from endpointManager
You can see, that i have the similar output with 2 connect requests:
EndpointReader received connect request message=server_connection:{SystemId:"8Y7ty56Y37qEU5GgQLtUpn" Address:"127.0.0.1:34443"}
EndpointReader received connect request message=server_connection:{SystemId:"Q2eebY9vXBwFkhUzS4ddWz" Address:"localhost:22333"}
As the result, interaction between client and server doesn't work. So, usage of AdvertisedHost
property doesn't help me for this issue.
@rogeralsing has comments?
Describe the bug I made server and client apps with help of protoactor library as the transport. When server has real address (e.g.
127.0.0.1
), then all work well. When server has0.0.0.0
address, then interaction between server and client doesn't work.To Reproduce I have the following definition with messages for protobuf:
I have the following definition of server app:
I have the following definition of client app:
Let's server has
127.0.0.1
address (defined inhost
const in the server app definition). When we start server first and after that - client, then we have the following output on server:and on client:
Let's server has
0.0.0.0
address (defined inhost
const in the server app definition). When we start server first and after that - client, then we have the following output on server:and on client:
Anyone can see the following:
127.0.0.1
address, interaction between server and client has place: client sends RequestTypeA message on server and receives ResponseTypeA message from server.0.0.0.0
address, interaction between server and client doesn't have place: anyone can see the following error on client -Request error "future: timeout"
127.0.0.1
address, anyone can see only one connect request:2023/03/22 19:45:20 DEBUG [REMOTE] EndpointReader received connect request message=server_connection:{SystemId:"CxAjoFiLPXHXCXp5yoUPJW" Address:"127.0.0.1:34444"}
0.0.0.0
address, anyone can see two connect requests:2023/03/22 19:53:18 DEBUG [REMOTE] EndpointReader received connect request message=server_connection:{SystemId:"JgBn2wcP3TNW4HwP9Gm9vg" Address:"127.0.0.1:34444"}
and2023/03/22 19:53:18 DEBUG [REMOTE] EndpointReader received connect request message=server_connection:{SystemId:"5UKtdU7DkjnAovWJ65fsvQ" Address:"[::]:23333"}
Expected behavior Server must work correctly and equally for both case of addresses - real (e.g.,
127.0.0.1
) and0.0.0.0
. Moreover, I made the same example on .NET with help of protoactor.NET library and this example work correctly for both case of addresses - real (e.g.,127.0.0.1
) and0.0.0.0
.Screenshots None
Additional context None