title: Unable to connect to gRPC server when build as jar
body: <p>I am trying gRPC and I having some issues. I have build a gRPC server and a client. Did almost the same as the java example of gRPC (<a href="https://grpc.io/docs/languages/java/basics/" rel="nofollow noreferrer">https://grpc.io/docs/languages/java/basics/</a>) so nothing special. Now when I create a jar of the server it runs well but when I create a jar of my client it throws the following exception:</p>
  <pre><code>Exception in thread &quot;main&quot; io.grpc.StatusRuntimeException: UNAVAILABLE: io exception
  at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:271)
  at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:252)
  at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:165)
  at com.example.grpc.server.classifier.classifierGrpc$classifierBlockingStub.classify(classifierGrpc.java:210)
  at com.example.grpc.client.Main.sendMessage(Main.java:35)
  at com.example.grpc.client.Main.main(Main.java:29)
  Caused by: io.grpc.netty.shaded.io.netty.channel.AbstractChannel$AnnotatedConnectException: connect(..) failed: Invalid argument: /172.16.3.14:530
  Caused by: java.net.ConnectException: connect(..) failed: Invalid argument
  at io.grpc.netty.shaded.io.netty.channel.unix.Errors.newConnectException0(Errors.java:155)
  at io.grpc.netty.shaded.io.netty.channel.unix.Errors.handleConnectErrno(Errors.java:128)
  at io.grpc.netty.shaded.io.netty.channel.unix.Socket.connect(Socket.java:313)
  at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel.doConnect0(AbstractEpollChannel.java:773)
  at io.grpc.netty.shaded.io.netty.channel.epoll.EpollSocketChannel.doConnect0(EpollSocketChannel.java:144)
  at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel.doConnect(AbstractEpollChannel.java:758)
  at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.connect(AbstractEpollChannel.java:600)
  at io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipeline$HeadContext.connect(DefaultChannelPipeline.java:1342)
  at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeConnect(AbstractChannelHandlerContext.java:548)
  at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:533)
  at io.grpc.netty.shaded.io.netty.channel.ChannelDuplexHandler.connect(ChannelDuplexHandler.java:54)
  at io.grpc.netty.shaded.io.grpc.netty.WriteBufferingAndExceptionHandler.connect(WriteBufferingAndExceptionHandler.java:157)
  at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeConnect(AbstractChannelHandlerContext.java:548)
  at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.access$1000(AbstractChannelHandlerContext.java:61)
  at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext$9.run(AbstractChannelHandlerContext.java:538)
  at io.grpc.netty.shaded.io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
  at io.grpc.netty.shaded.io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
  at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
  at io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:394)
  at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:995)
  at io.grpc.netty.shaded.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
  at io.grpc.netty.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
  at java.base/java.lang.Thread.run(Thread.java:829)
  </code></pre>
  <p>This does not happen when I run the client in Intellij.</p>
  <p>After searching for a while I found some posts that suggest using flag <code>java.net.preferIPv4Stack=true</code> to force ipv4 usage but that did not work.</p>
  <p>Some versions of protobuf &amp; gRPC</p>
  <pre><code>    implementation 'com.google.protobuf:protobuf-java:3.21.5'
      implementation 'io.grpc:grpc-netty-shaded:1.49.0'
      implementation 'io.grpc:grpc-protobuf:1.49.0'
      implementation 'io.grpc:grpc-stub:1.49.0'
  </code></pre>
  <p>So to be clear, the client works when it is run in Intellij but not when build as a jar.</p>