0

I'm building a test gRPC server with Mill using ScalaPBModule. I can successfully build (with server.assembly) and start the server, but when it is hit with a request, the client throws this error:

Suppressed: java.nio.channels.UnsupportedAddressTypeException: null at java.base/sun.nio.ch.Net.checkAddress(Net.java:127) ... io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)

(I am sure there is no problem with the client.)

Here is my build config:

object server extends ScalaPBModule {
  def scalaVersion = "2.13.5"
  def scalaPBVersion = "0.11.12"
  override def scalaPBGrpc = true

  def ivyDeps = Agg(
    ivy"dev.zio::zio:2.0.5",
    // ivy"dev.zio::zio_3:2.0.5",
    // ivy"dev.zio::zio-direct:1.0.0-RC1",
    ivy"dev.zio::zio-direct:1.0.0-RC1+8-da53f9ae-SNAPSHOT",
    // ivy"dev.zio::zio-direct_3:1.0.0-RC1",
    ivy"org.mongodb.scala::mongo-scala-driver:4.8.0",
    ivy"io.grpc:grpc-netty:1.51.1", // ${scalapb.compiler.Version.grpcJavaVersion}",
    ivy"io.grpc:grpc-alts:1.51.1",
    ivy"io.grpc:grpc-protobuf:1.51.1",
    ivy"io.grpc:grpc-stub:1.51.1",
    ivy"io.grpc:grpc-testing:1.51.1",
    ivy"com.thesamet.scalapb::scalapb-runtime-grpc:0.11.12",
    ivy"com.thesamet.scalapb.zio-grpc::zio-grpc-core:0.0.0+1-02300782-SNAPSHOT"
  )
}

I see others reporting this problem with gradle and maven and solving it with shadowing, etc. - how can this be done with Mill? Appreciate any help!

EDIT: The problem is the client, not the server; here is my client code.

EDIT 2: The code is irrelevant; it's a packaging issue as I suggested initially.

object Main extends ZIOAppDefault {
  val app = for {
    args <- getArgs
    channel <- ZIO.attempt(ManagedChannelBuilder.forAddress(args(0), 50051).usePlaintext().build)
    stub <- ZIO.attempt(TestGrpc.stub(channel))
    _ <- ZIO.fromFuture(_ => createMessage(stub))
  } yield ()

Client deps are the same.

  • The list of dependencies for the server is fine. There isn’t enough information here to tell what the problem is. Can you try using a generic grpc command line client to rule out that the issue is the client? Please provide code for the server. – thesamet Jan 03 '23 at 15:22
  • @thesamet Thanks a ton. I ran another client and, indeed, the problem is actually with the client. The client has the same deps and calls the server like this: – Bender Rodriguez Jan 03 '23 at 18:01
  • ```object Main extends ZIOAppDefault { val app = for { args <- getArgs channel <- ZIO.attempt(ManagedChannelBuilder.forAddress(args(0), 50051).usePlaintext().build) stub <- ZIO.attempt(TestGrpc.stub(channel)) _ <- ZIO.fromFuture(_ => createMessage(stub)) } yield ()``` – Bender Rodriguez Jan 03 '23 at 18:03
  • This is unreadable so I'll edit the question. – Bender Rodriguez Jan 03 '23 at 18:06
  • What is the parameter you are passing to client? Should be "localhost" or "127.0.0.1" – thesamet Jan 03 '23 at 18:59
  • Another possible reason is the way you might be assembling the client. See https://stackoverflow.com/a/73349585/97524 – thesamet Jan 03 '23 at 19:41
  • I've tried both as well as binding the server to a specific IP (using NettyServerBuilder.forAddress(address)) and using that. (I used ```Ipconfig getifaddr en0``` to determine the IP to bind to.) The call never gets to the server impl method but the channel and stub are constructed successfully. However, I've noted that that occurs even with an invalid address so it's meaningless. So yeah I did consider an issue with the hostname but it doesn't seem to be the case. – Bender Rodriguez Jan 03 '23 at 19:42
  • @thesamet Yes, I DO suspect an issue with the assembly which is why I posted this thread! The only thing is that I assumed it was the server build when it is the client. As I stated in the question, I don't know how to accomplish this shading with Mill. I am using mill to assemble the client (and server). If I were using sbt (or even gradle) I could solve this easily. It's a Mill issue... – Bender Rodriguez Jan 03 '23 at 19:45
  • See this https://com-lihaoyi.github.io/mill/mill/Configuration.html#_mergeexcluderelocate_files_from_assembly for how to set merge strategy. – thesamet Jan 03 '23 at 21:02

0 Answers0