天道酬勤,学无止境

grpc

Microservices with gRPC and REST using Spring Boot

问题 回答1 您可以查看 LogNet grpc-spring-boot-starter 以了解如何将 gRPC 集成到 Spring Boot 中,它还有一个关于 Eureka 的部分。 根据 Eureka 示例,请确保您没有通过 gRPC 为每个调用创建新连接。 根据 API 网关的实现,它还应该与 Eureka 通信,并通过 gRPC 按逻辑名称访问下游服务。 按照第二部分,只需在 Spring Services 中实现您的业务逻辑,并从传输相关的抽象(控制器和 gRPC 服务)转发对它们的调用。 或者,您可以更进一步,仅在 Protobuf 中定义所有消息。 然后注册 Spring 的 Protobuf Converter for HTTP。

2022-05-16 16:36:16    分类:技术分享    java   spring   spring-boot   grpc

Use SSL in gRPC client server communication

问题 我对 SSL/TLS 一无所知,并尝试按照在线上的说明在 gRPC 中使用 SSL/TLS 通道。 这是服务器代码: std::string server_address("0.0.0.0:50051"); GreeterServiceImpl service; grpc::SslServerCredentialsOptions::PemKeyCertPair pkcp ={"a","b"}; grpc::SslServerCredentialsOptions ssl_opts; ssl_opts.pem_root_certs=""; ssl_opts.pem_key_cert_pairs.push_back(pkcp); std::shared_ptr<grpc::ServerCredentials> creds; creds = grpc::SslServerCredentials(ssl_opts); ServerBuilder builder; builder.AddListeningPort(server_address, creds); builder.RegisterService(&service); std::unique_ptr<Server> server(builder.BuildAndStart()); 服务器将无法启动并因以下错误而终止。

2022-05-15 12:59:04    分类:技术分享    ssl   grpc

grpc dart server and client exmple with secure connection

I have searched for grpc secure server and client example in dart I couldn't find any, example of creating insecure connection can be found but this is not what I am looking for. I have managed to compile it with secure but getting grpc error when connecting between client to server Caught error: gRPC Error (code: 14, codeName: UNAVAILABLE, message: Error connecting: HandshakeException: Connection terminated during handshake, details: null, rawResponse: null) My Server credentials implementation: final String myPath = 'password_file.pem'; final File f = File(myPath); final Uint8List bytes = f

2022-05-03 05:50:14    分类:问答    dart   security   protocol-buffers   grpc   credentials

How do i handle streaming messages with Python gRPC

I'm following this Route_Guide sample. The sample in question fires off and reads messages without replying to a specific message. The latter is what i'm trying to achieve. Here's what i have so far: import grpc ... channel = grpc.insecure_channel(conn_str) try: grpc.channel_ready_future(channel).result(timeout=5) except grpc.FutureTimeoutError: sys.exit('Error connecting to server') else: stub = MyService_pb2_grpc.MyServiceStub(channel) print('Connected to gRPC server.') this_is_just_read_maybe(stub) def this_is_just_read_maybe(stub): responses = stub.MyEventStream(stream()) for response in

2022-05-03 03:58:30    分类:问答    python   stream   grpc

Get subject DN from clients certificate in Go gRPC handler

I'm using Golang gRPC with mutual tls. Is it possible to get client's certificate subject DN from rpc method? // ... func main() { // ... creds := credentials.NewTLS(&tls.Config{ ClientAuth: tls.RequireAndVerifyClientCert, Certificates: []tls.Certificate{certificate}, ClientCAs: certPool, MinVersion: tsl.VersionTLS12, }) s := NewMyService() gs := grpc.NewServer(grpc.Creds(creds)) RegisterGRPCZmqProxyServer(gs, s) er := gs.Serve(lis) // ... } // ... func (s *myService) Foo(ctx context.Context, req *FooRequest) (*FooResonse, error) { $dn := // What should be here? // ... } Is it possible?

2022-05-03 02:53:08    分类:问答    go   ssl-certificate   tls1.2   grpc   mutual-authentication

Is it possible to perform two speech-to-text streams at same time from one account?

So, question is on title, I can create speech to text stream to one user and it works nice, but when I try to connect second user, it works bad for all, sometimes it works good for one user, so question is, can I create sppech-to-text stream for two or more users at same time with one GOOGLE_APPLICATION_CREDENTIALS or each user need start his own project?

2022-05-03 01:30:02    分类:问答    speech-recognition   grpc   speech-to-text   google-cloud-speech   google-speech-to-text-api

How to upload an image in chunks with client-side streaming gRPC using grpcurl

I have been trying to upload an image in chunks with client side streaming using grpcurl. The service is working without error except that at the server, image data received is 0 bytes. The command I am using is: grpcurl -proto image_service.proto -v -d @ -plaintext localhost:3010 imageservice.ImageService.UploadImage < out This link mentions that the chunk data should be base64 encode and so the contents of my out file are: {"chunk_data": "<base64 encoded image data>"} This is exactly what I am trying to achieve, but using grpcurl. Please tell what is wrong in my command and what is the best

2022-05-03 01:23:21    分类:问答    protocol-buffers   grpc   grpc-go   grpcurl

get message from gRPC java server side interceptor

I am writing a gRPC server side interceptor in java. I simplely want to access the request message and read one field from the message. But after 1 day of googling and talking with others, I couldn't find how to do it. Any idea how to do it? import io.grpc.Metadata; import io.grpc.ServerCall; import io.grpc.ServerCallHandler; import io.grpc.ServerInterceptor; public class EventInterceptor implements ServerInterceptor { @Override public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall( ServerCall<ReqT, RespT> serverCall, Metadata metadata, ServerCallHandler<ReqT, RespT> serverCallHandler)

2022-05-02 23:52:35    分类:问答    grpc   interceptor   grpc-java

Check if gRpc server is running in C#

I am writing a gRpc server in C# and I wanted to add automatic recovery/retry implementation if server is down for any reason. Upon researching, i came across interceptors and got excited but looks like it is supported only for Go. I cannot find anything similar for gRpc C#. How can automatic recovery be handled in gRpc CSharp or is there any similar concept like interceptors that we can use ? EDIT- in GRPC c#, is there a way to check if the server is running or available ?

2022-05-02 23:28:09    分类:问答    c#   service   grpc

How to write a GRPC python unittest

问题 我们使用 grpc 作为我们所有内部系统的 RPC 协议。 大多数系统是用Java编写的。 在 Java 中,我们可以使用 InprocessServerBuilder 进行单元测试。 但是,我在 Python 中没有找到类似的类。 任何人都可以提供如何在 python 中进行 GRPC 单元测试的示例代码吗? 回答1 回答2 一些示例代码开始: 原型 syntax = "proto3"; service MyLibrary { rpc Search (Request) returns (Response); } message Request { string id = 1; } message Response { string status = 1; } 蟒蛇单元测试 #!/usr/bin/env python # coding=utf-8 import unittest from grpc import StatusCode from grpc_testing import server_from_dictionary, strict_real_time import mylibrary_pb2 class TestCase(unittest.TestCase): def __init__(self, methodName) -> None: super()._

2022-05-02 20:42:45    分类:技术分享    python   python-3.x   grpc