首页 > 解决方案 > 无法在 32 位 windows 机器上创建 grpc 连接

问题描述

我正在尝试使用我的 java 代码和 GCP 提供的几个库来访问我的 GCP 项目中的订阅者列表。此代码在我的 64 位 Windows 环境中运行良好,但在 32 位 Windows 环境中无法运行。

我在一些文档中看到,说 netty 在 32 位机器上不支持,如果需要,我们可以构建自己的二进制文件。

https://netty.io/wiki/forked-tomcat-native.html#how-to-build

CredentialsProvider credentialsProvider = FixedCredentialsProvider.create( ServiceAccountCredentials.fromStream(new FileInputStream(JSONPath))); try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create(SubscriptionAdminSettings.newBuilder().setCredentialsProvider(credentialsProvider).build())) { ListSubscriptionsRequest listSubscriptionsRequest = ListSubscriptionsRequest.newBuilder() .setProject(ProjectName.of(ProjectId).toString()) .build(); SubscriptionAdminClient.ListSubscriptionsPagedResponse response = subscriptionAdminClient.listSubscriptions(listSubscriptionsRequest); logger.log(Level.SEVERE,"response List: "+response.toString()); Iterable<Subscription> subscriptions = response.iterateAll(); for (Subscription subscription : subscriptions) { if(subscription.getName().equals(SubscriptionId)){ return true; } }

[20:02:30:384]|[06-17-2019]|[io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts]|[INFO]|[36]:netty-tcnative 不可用(此可能是正常的)| java.lang.IllegalArgumentException:无法加载任何给定库:[netty_tcnative_windows_x86_32,netty_tcnative_x86_32,netty_tcnative] at io.grpc.netty.shaded.io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:104) at io.grpc.netty.shaded.io.netty.handler.ssl.OpenSsl.loadTcNative(OpenSsl.java:526) 在 io.grpc.netty.shaded.io.netty.handler.ssl.OpenSsl.(OpenSsl.java: 93)在io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts.defaultSslProvider(GrpcSslContexts.java:244)在io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java: 171) 在 io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts。

标签: javagoogle-cloud-platformnettygoogle-cloud-pubsub

解决方案


您回答了自己的问题... netty-tcnative-* 不支持 32 位平台,因此您需要自己编译并将其包含在您的类路径中。


推荐阅读