I am trying to run 2 different akka grpc servers however they cannot run concurrently. I try binding one server on localhost port 8080 and the other one on localhost port 8090. Separate they run fine but when I try to run them together I get the following error:
[ERROR] [05/13/2021 11:14:30.862] [Server-akka.actor.internal-dispatcher-6] [akka://Server/system/IO-TCP/selectors/$a/0] Bind failed for TCP channel on endpoint [/192.168.1.10:25520]
java.net.BindException: [/192.168.1.10:25520] Address already in use: bind
Here is the code were I try to create them:
val service: HttpRequest => Future[HttpResponse] =
StoreServiceHandler(new StoreImpl())
// Bind service handler servers to localhost:8080/8081
val binding = Http().newServerAt("127.0.0.1", 8080).bind(service)
// report successful binding
binding.foreach { binding => println(s"gRPC server bound to: ${binding.localAddress}")
and
val service: HttpRequest => Future[HttpResponse] =
CommunicationChannelHandler(new CommunicationChannelImpl())
// Bind service handler servers to localhost:8080/8081
val binding = Http().newServerAt("127.0.0.1", 8090).bind(service)
// report successful binding
binding.foreach { binding => println(s"gRPC server bound to: ${binding.localAddress.getPort}") }
Note: the print statement returns the right ports so I do not understand why they cannot run together/ why they both try to use port 2552.