我有一个托管在 Firebase 中的现有 webapp 项目,我想向其中添加云功能。但是,当我仅使用该命令运行时,firebase init functions由于 gRPC 节点模块中的错误,它生成的初始 hello-world 模板无法在 TypeScript 中编译。
我的文件夹结构:
\nfirebase\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 .firebaserc\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 firebase.json\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 webapp // My web app. Compiles and runs well.\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 package.json\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 tsconfig.json\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 src\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 functions // Only what was autogenerated by firebase-tools.\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 .eslintrc.js\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 package.json\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 tsconfig.json\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 tsconfig.dev.json\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 src\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 index.ts\nRun Code Online (Sandbox Code Playgroud)\n我做了什么
\n在我的firebase根文件夹中,我运行firebase init functions并选择了正确的项目,使用 TypeScript,具有默认的 ESLint 定义,并安装软件包。
我注释掉了 中的 Hello World 函数functions/src/index.ts。
我正在使用最新的 Node …
firebase typescript firebase-tools google-cloud-functions grpc-node
我有一个 gRPC 服务器,可以无限期地传输数据。它生成一个子进程来检索一些硬件资源统计信息。
我想要的是取消来自客户端的 gRPC 调用,以便我可以终止生成的进程。另一种解决方案是在客户端断开连接时在服务器上进行检测,以便我可以终止该进程。
我在客户端和服务器上都使用 grpc-node 。
我似乎还不知道该怎么做......
如何增加 Node.js gRPC 客户端的最大消息大小?
我们使用grpc,grpc-tools和protobufjsnpm-packages:
const packageDefinitions = loader.loadSync(PROTO_PATH, { includeDirs: [__dirname], longs: String, arrays: true });
const packageObject = grpc.loadPackageDefinition(packageDefinitions);
const client = new packageObject.Service(serviceAddress, grpc.credentials.createInsecure());
Run Code Online (Sandbox Code Playgroud) 我正在使用使用 HTTPS 和自签名证书托管的 GRPC 服务。当我使用如下语法进行连接时:
const client = new productService('https://grpc-server-xxx.com:9090',
grpc.credentials.createInsecure())
Run Code Online (Sandbox Code Playgroud)
我收到这样的错误
{ Error: 14 UNAVAILABLE: DNS resolution failed
at Object.exports.createStatusError (C:\grpc\node_modules\grpc\src\common.js:91:15)
at Object.onReceiveStatus (C:\grpc\node_modules\grpc\src\client_interceptors.js:1209:28)
at InterceptingListener._callNext (C:\grpc\node_modules\grpc\src\client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (C:\grpc\node_modules\grpc\src\client_interceptors.js:618:8) at callback (C:\grpc\node_modules\grpc\src\client_interceptors.js:847:24)code: 14,metadata: Metadata { _internal_repr: {}, flags: 0 },details: 'DNS resolution failed'
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮助我如何解决这个问题。
注意:我的操作系统是 Windows 10,nodejs -- v10.16.0,GRPC
我是使用 GCP/Kubernetes 的新手。我想将 GRPC 服务和客户端部署到 GCP。
我读过很多相关内容并尝试过一些事情。云端点上有一些东西,您可以在其中编译原型文件并执行 api.config.yaml。(https://cloud.google.com/endpoints/docs/grpc/get-started-grpc-kubernetes-engine)
这不是我想做的。我想上传一个 GRPC 服务及其 .proto 并公开其 HTTP/2 公共 IP 地址和端口。然后,部署与该地址交互并公开 REST 端点的 GRPC 客户端。
我怎样才能完成这件事?
google-cloud-platform kubernetes google-kubernetes-engine grpc grpc-node
我想将我的 .proto 文件编译成存根,但是在输入命令时:
`protoc -I=. ./protos/dummy.proto --js_out=import_style=commonjs,binary:./server --grpc_out=./server --plugin=protoc-gen-grpc=which grpc_tools_node_protoc_plugin
我收到以下错误:
--grpc_out: protoc-gen-grpc: %1 is not a valid Win32 application.
Run Code Online (Sandbox Code Playgroud)
我已经安装了:
注意:我注意到已经有一些类似的问题,但我没有找到针对 Node.js 的问题,而且已经提出的问题都有不同的解决方案。
我想问如何编码(序列化)映射字段。
根据谷歌指南,“JavaScript生成的代码”包含以下地图字段函数。getFooMap()生成解码函数( )。但我在任何地方都找不到地图类型的编码函数或指南。(我以为会有类似的功能setXXXMap(),但我找不到。)
我应该如何编码地图字段?
https://developers.google.com/protocol-buffers/docs/reference/javascript- generated#map
地图字段
对于此带有地图字段的消息:
message Bar {}
message Baz {
map<string, Bar> foo = 1;
}
Run Code Online (Sandbox Code Playgroud)
编译器生成以下实例方法:
getFooMap():返回包含foo的键值对的Map。然后,您可以使用 Map 方法与地图进行交互。
grpc-node ×7
grpc ×5
node.js ×4
firebase ×1
grpc-go ×1
grpc-java ×1
javascript ×1
kubernetes ×1
protobufjs ×1
typescript ×1