In io.grpc.internal.ManagedChannelImplBuilder 
<https://github.com/grpc/grpc-java/blob/master/core/src/main/java/io/grpc/internal/ManagedChannelImplBuilder.java#L824>
 it 
does a
  *provider = 
nameResolverRegistry.getProviderForScheme(targetUri.getScheme());*
The NameResolverRegistry has 2 entries when I tried with localhost url: 
"dns" -> DnsNameResolverProvider and "unix" -> UdsNameResolverProvider.

For *localhost *java.net.URI getScheme will return null so the 
ManagedChannelImplBuilder will fallback 
<https://github.com/grpc/grpc-java/blob/master/core/src/main/java/io/grpc/internal/ManagedChannelImplBuilder.java#L831>
 to 
the default scheme. The default scheme is taken from the name resolver 
provider with the highest priority which is *DnsNameResolverProvider *in 
this case, whose scheme is *dns.*
In your case when you run from the command line apparently only the 
*UdsNameResolverProvider* gets registered but not the *DnsNameResolverProvider, 
*and produces a socket address type not supported by Netty.

Can you run with fine logging enabled so that it prints why a name resolver 
provider could not be loaded here 
<https://github.com/grpc/grpc-java/blob/master/api/src/main/java/io/grpc/NameResolverRegistry.java#L137>
?


On Wednesday, May 22, 2024 at 9:33:43 PM UTC+5:30 Akash Sinha wrote:

> Hello Everyone, 
>
> I am trying to build a JAVA based gRPC client that tries to communicate 
> with Python based gRPC server. I am getting the following exception when I 
> run the code from terminal using the JAR file.  
>
> Exception in thread "main" 
> io.grpc.ManagedChannelRegistry$ProviderNotFoundException: 
> io.grpc.netty.shaded.io.grpc.netty.NettyChannelProvider: does not support 1 
> or more of [class 
> io.grpc.netty.shaded.io.netty.channel.unix.DomainSocketAddress]
>
> at 
> io.grpc.ManagedChannelRegistry.newChannelBuilder(ManagedChannelRegistry.java:204)
>
> at 
> io.grpc.ManagedChannelRegistry.newChannelBuilder(ManagedChannelRegistry.java:155)
>
> at io.grpc.Grpc.newChannelBuilder(Grpc.java:101)
>
> The error happens while executing the following code: 
> String target = "localhost:"+port;
>
> ManagedChannel channel = Grpc.newChannelBuilder(target, 
> InsecureChannelCredentials.create()).build(); 
>
> However, the code runs fine when running the main class from the IDE. I 
> have created the fat jar file using maven. Following is my pom.xml file. 
>
> <?xml version="1.0" encoding="UTF-8"?>
> <project xmlns="http://maven.apache.org/POM/4.0.0";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
> http://maven.apache.org/xsd/maven-4.0.0.xsd";>
> <modelVersion>4.0.0</modelVersion>
>
> <groupId>org.example</groupId>
> <artifactId>DummyEnv</artifactId>
> <version>1.0-SNAPSHOT</version>
> <dependencies>
> <dependency>
> <groupId>io.grpc</groupId>
> <artifactId>grpc-netty-shaded</artifactId>
> <version>1.63.0</version>
> <scope>runtime</scope>
> </dependency>
> <dependency>
> <groupId>io.grpc</groupId>
> <artifactId>grpc-protobuf</artifactId>
> <version>1.63.0</version>
> </dependency>
> <dependency>
> <groupId>io.grpc</groupId>
> <artifactId>grpc-stub</artifactId>
> <version>1.63.0</version>
> </dependency>
> <dependency> <!-- necessary for Java 9+ -->
> <groupId>org.apache.tomcat</groupId>
> <artifactId>annotations-api</artifactId>
> <version>6.0.53</version>
> <scope>provided</scope>
> </dependency>
>
>
> </dependencies>
> <properties>
> <maven.compiler.source>21</maven.compiler.source>
> <maven.compiler.target>21</maven.compiler.target>
> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> </properties>
>
> <build>
> <extensions>
> <extension>
> <groupId>kr.motd.maven</groupId>
> <artifactId>os-maven-plugin</artifactId>
> <version>1.7.1</version>
> </extension>
> </extensions>
> <plugins>
> <plugin>
> <groupId>org.xolstice.maven.plugins</groupId>
> <artifactId>protobuf-maven-plugin</artifactId>
> <version>0.6.1</version>
> <configuration>
> <protocArtifact
> >com.google.protobuf:protoc:3.25.1:exe:${os.detected.classifier}</
> protocArtifact>
> <pluginId>grpc-java</pluginId>
> <pluginArtifact
> >io.grpc:protoc-gen-grpc-java:1.63.0:exe:${os.detected.classifier}</
> pluginArtifact>
> </configuration>
> <executions>
> <execution>
> <goals>
> <goal>compile</goal>
> <goal>compile-custom</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-assembly-plugin</artifactId>
> <version>3.7.1</version>
> <configuration>
> <descriptorRefs>
> <descriptorRef>jar-with-dependencies</descriptorRef>
> </descriptorRefs>
> </configuration>
> <executions>
> <execution>
> <id>assemble-all</id>
> <phase>package</phase>
> <goals>
> <goal>single</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> </plugins>
> </build>
> </project>
>
> Can someone please help me in debugging this issue? 
>
> Thanks :) 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to grpc-io+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/120f281f-4dd7-4e50-814f-72bd478e5d70n%40googlegroups.com.

Reply via email to