grpc-node | 单独把官方地关于node例子拿出来使用
kandi X-RAY | grpc-node Summary
kandi X-RAY | grpc-node Summary
单独把官方地关于node例子拿出来使用
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of grpc-node
grpc-node Key Features
grpc-node Examples and Code Snippets
Community Discussions
Trending Discussions on grpc-node
QUESTION
I use gRPC but I have a problem initializing the service in Next.js app.
Goal: Create client service only once in app and use it in getServerSideProps
(app doesn't use client-side routing).
For example, we have a service generated with grpc-tools (only available on SSR) and then I just want to initialize it somewhere. At first I thought it can be realized in a custom server.js
:
ANSWER
Answered 2021-Apr-01 at 11:50For such a case you can use Node.js global
QUESTION
I was doing a proof of concept on gRPC using node.js
Here is my package.json
...ANSWER
Answered 2020-Nov-23 at 20:25After some research, I did the following steps to resolve the issue
I was missing node-gyp - which is Node.js native addon build tool. It can be installed by
npm install -g node-gyp
Install Python
Install Visual C++ Build Environment
Clean up node-modules
Then do in the folder
npm install
The following link talks the above steps in detail: https://github.com/nodejs/node-gyp#on-windows
QUESTION
Does GRPC Middleware library support grpc-node? I'm interested in logging grpc proto requests, and it seems like I might have to learn golang in order to have a logging feature?
...ANSWER
Answered 2020-Aug-05 at 17:40Definitely you don't need to learn Golang for that. You just need to check how to use gRPC interceptors with node. In the interceptor code you will implement any of those features available in the gRPC middleware for Golang.
It would be something like that
QUESTION
Grpc version: 1.24.2
When deploying my Node.js app I have a problem with the binary file for grpc package.
Error:
...ANSWER
Answered 2020-Jun-04 at 17:12Module version 83 corresponds to Node 14, not 13. Unfortunately, we have not yet published binaries for Node 14, so it's going to be difficult to get that working
Full answer - https://github.com/grpc/grpc-node/issues/1460#issuecomment-638965479
QUESTION
Will a bidirectional RPC call ever open multiple http2 connections?
I'm writing a GRPC client that's talking to a GRPC server I don't own/control. I'm using the @grpc/grpc-js package. I've been asked whether this library will open multiple HTTP2 connections to the grpc endpoint and I'm not familiar enough with the source code to answer this question. My code for making a call and opening a stream looks like this
...ANSWER
Answered 2020-Mar-31 at 16:48No matter what streaming type the request is, gRPC will use each single connection to open multiple streams. This is one major reason HTTP/2 was chosen as the underlying protocol for gRPC: multiplexing streams onto connections is already part of that protocol.
Of the classes you mentioned, the Channel
is the API-level abstraction over connections. A Channel represents any number of connections to backends referred to by the target string. It will automatically establish connections as needed to handle any requests that are initiated.
The Resolver
, which you didn't mention, determines what backend addresses are associated with the target string. For example, the DnsResolver
will look up DNS records.
A LoadBalancer
determines what specific connections to establish and how to distribute requests among those connections. The default load balancing policy, "pick first" just sends all requests to whichever connection is successfully established first. There is also the "round robin" load balancing policy, which tries to establish connections to multiple backends and then cycles through them when starting calls.
A Subchannel
represents a connection to a single backend, that can be reestablished if it drops.
The filter stack applies some transformations to requests between when they are initiated at the top-level API and when they are sent out on the network.
QUESTION
When creating a GRPC client in NodeJS, if I'm using the grpc
package, I can start my program with the GRPC_VERBOSITY
set to debug
environmental variable.
ANSWER
Answered 2020-Mar-30 at 19:01As can be seen here:
QUESTION
Framing: Experienced engineer/developer dealing with GRPC and HTTP2 for the first time ever, and dealing with streaming programming for the first time in a long time.
What event(s) do I need to be aware of in order to successfully detect a "failure" (server disconnects expectedly, server disconnects unexpectedly, server has a timeout and goes away, etc.) in a GRPC server when using the @grpc/grpc-js
package?
That is -- we have a GRPC service that's using protobuffers, and we can call/setup a stream something like this
...ANSWER
Answered 2020-Mar-26 at 21:52The short answer is that a gRPC call will generally end with a status
with status.code
equal to grpc.status.UNAVAILABLE
, so you should be able to accomplish what you want by listening for a status/error with that code and re-establishing the stream when that happens.
First, I want to explain the overall lifecycle of a gRPC request. After starting a request, you will usually first get a metadata
event containing response headers. Then you will perform some number of write
operations and receive some number of data
events. Then the stream will end, and a few semi-redundant events will trigger. The end
event indicates that there is no more data to read, but has no additional information. The close
event might also trigger here, but I never use it. The status
event provides a status object that says how the stream ended. A .code
equal to grpc.status.OK
indicates that the stream completed successfully. In any other case, an error
event will also be emitted, and the error
object will additionally have all of the same fields that the status has. You should always listen for the error
event, because if you do not and one is emitted, Node will automatically bubble it up and throw it as a global exception.
If a stream ends for any reason, including a server disconnection, it will end with a status
event. Network errors, including server disconnections, are usually indicated by the UNAVAILABLE
status code. That code is also used when a connection could not be established at all.
For the most part, gRPC is an abstraction over connections anyway. A single gRPC client can be backed by multiple TCP connections, and if a connection is dropped gRPC will automatically try to re-establish the connection.
QUESTION
Note that this is not a duplicate of a similar question for go, since this uses grpc-node
. For some reason, there seems to be differences in the API
I do the standard procedure of creating my APIPackageDefinitions and APIPackagePbjects, and create two separate clients from each one, individually.
...ANSWER
Answered 2020-Mar-11 at 22:33There is an API to do this, but it is a bit more awkward than what you were trying. And you don't actually need to use it to get what you want. The grpc library internally pools connections to the same server, as long as those connections were created with identical parameters. So, the Client
objects created in your first code block will actually use the same TCP connection.
However, as mentioned, there is a way to do this explicitly. The third argument to the Client
constructor is an optional object with various additional options, including channelOverride
. That accepts a Channel
object like the one you constructed at the beginning of your second code block. You still have to pass valid values for the first two arguments, but they will actually be ignored and the third argument will be used instead. You can see more information about that constructor's arguments in the API documentation.
QUESTION
See https://github.com/grpc/grpc-node/issues/1202.
Usually in CRUD operations, the value not provided means do not change that field, and the empty array [] means to clear all items inside that field.
But if you tries to implement CRUD operations and provide them as services via grpc, then the above scenario is hard to implement.
...ANSWER
Answered 2019-Nov-27 at 18:28The protobuf encoding doesn't distinguish between these two cases. Since protobuf is language-agnostic, it doesn't understand the conceptual nuance of "undefined" versus "[]" of Javascript.
You would need to pass additional information inside the proto message in order to distinguish between the two cases.
I would highly suggest reading the design documentations here: https://developers.google.com/protocol-buffers
QUESTION
I'm trying to push the changes to my NodeJS web app to heroku; however, I encounter the following error message during the build phase. I know the issue lies with "grpc" (refer to the error message), which I suspect is a dependency of firebase; however, I don't know how to resolve the issue. Here is a very similar issue I found on SO but there is no clear solution on that thread.
...ANSWER
Answered 2018-Jun-13 at 18:04The primary problem here is that the version of gRPC you are trying to install is not compatible with the version of Node that you are using. That error indicates that you are installing gRPC@1.10.1 with Node 10; the first version of gRPC that supports Node 10 is gRPC@1.11.1. So, in general the solution to this problem would be to either downgrade your Node version, or upgrade your gRPC version.
Your edit seems to indicate that you were able to solve this by downgrading the versions of the firebase
, firebase-admin
, and firebase-tools
packages that you are using. This probably works because the specific versions you tried first pinned the gRPC dependency to the older version, and downgrading got you a version that didn't have the dependency pinned. However, each of those packages also has newer versions that don't pin the gRPC dependency and should give you the newest version.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install grpc-node
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page