https://cerbos.dev logo
#help
Title
j

Jay StGelais

03/10/2023, 6:51 PM
I'm having some issues with the Java Client. We have followed the deployment setup outlined here to deploy Cerbos as a k8s sidecar. Instead of the ghostunnel application we have a spring-boot API that is using the Java client. We use the following code to iniatlize the client:
Copy code
final CerbosBlockingClient cerbosClient = new CerbosClientBuilder("unix:/sock/cerbos.sock").withPlaintext().buildBlockingClient();
The client is created without error, but once we try to issue an API call, we get the following error in our logs:
Copy code
nested exception is dev.cerbos.sdk.CerbosException: RPC exception [Status{code=UNAVAILABLE, description=io exception, cause=io.grpc.netty.shaded.io.netty.channel.AbstractChannel$AnnotatedConnectException: connect(..) failed: Address family not supported by protocol: /sock/cerbos.soc
Not sure if we are specifying the unix socket correctly in this example and struggling to find examples online that do this.
If it helps, here is the full stacktrace
Copy code
Caused by: java.net.ConnectException: connect(..) failed: Address family not supported by protocol
 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:391)
 at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
 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(Unknown Source)
}]] with root cause
java.net.ConnectException: connect(..) failed: Address family not supported by protocol
 at io.grpc.netty.shaded.io.netty.channel.unix.Errors.newConnectException0(Errors.java:155) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at io.grpc.netty.shaded.io.netty.channel.unix.Errors.handleConnectErrno(Errors.java:128) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at io.grpc.netty.shaded.io.netty.channel.unix.Socket.connect(Socket.java:313) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel.doConnect0(AbstractEpollChannel.java:773) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at io.grpc.netty.shaded.io.netty.channel.epoll.EpollSocketChannel.doConnect0(EpollSocketChannel.java:144) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel.doConnect(AbstractEpollChannel.java:758) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.connect(AbstractEpollChannel.java:600) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipeline$HeadContext.connect(DefaultChannelPipeline.java:1342) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeConnect(AbstractChannelHandlerContext.java:548) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:533) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at io.grpc.netty.shaded.io.netty.channel.ChannelDuplexHandler.connect(ChannelDuplexHandler.java:54) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at io.grpc.netty.shaded.io.grpc.netty.WriteBufferingAndExceptionHandler.connect(WriteBufferingAndExceptionHandler.java:157) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeConnect(AbstractChannelHandlerContext.java:548) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.access$1000(AbstractChannelHandlerContext.java:61) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext$9.run(AbstractChannelHandlerContext.java:538) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at io.grpc.netty.shaded.io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at io.grpc.netty.shaded.io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:391) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at io.grpc.netty.shaded.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at io.grpc.netty.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[grpc-netty-shaded-1.53.0.jar:1.53.0]
 at java.base/java.lang.Thread.run(Unknown Source) ~[na:na]
c

Charith (Cerbos)

03/10/2023, 7:05 PM
Hi, try with
unix:///sock/cerbos.sock
j

Jay StGelais

03/10/2023, 7:06 PM
I have tried with the 3 slashes as well and get the same error
Let me try again though in case I might have mistypesd something the last time
c

Charith (Cerbos)

03/10/2023, 7:10 PM
Oh, it could be because
grpc-java
doesn't support Unix domain sockets (https://github.com/grpc/grpc-java/issues/1539). Perhaps try with TCP? If you are using a side car, you can make Cerbos listen on 127.0.0.1 only so it won't be accessible from the outside anyway.
j

Jay StGelais

03/10/2023, 7:10 PM
That's good to know. We'll go that route.
Alright.... Got further, but now it looks like I'm hitting an issue that is probably my own doing, but unfortunately the error being logged is rather opaque.
Copy code
dev.cerbos.sdk.CerbosException: RPC exception [Status{code=INTERNAL, description=Resources query plan request failed, cause=null}]] with root cause
dev.cerbos.sdk.CerbosException: RPC exception [Status{code=INTERNAL, description=Resources query plan request failed, cause=null}]
 at dev.cerbos.sdk.CerbosBlockingClient.plan(CerbosBlockingClient.java:149) ~[cerbos-sdk-java-v0.5.0.jar:na]
...
Is there a way to turn request logging on for the client, to capture the post bodies?
nevermind, found the error in the cerbos log
13 Views