[grpc-io] Re: [Golang]How to Choose RPC type when it is required to send data from both side of the application

2020-09-16 Thread 'Easwar Swaminathan' via grpc.io
I'm not sure if I understood your question correctly, but your application 
could be structured as follows (based on my understanding).

Server exposes the following methods:
- Registration (unary)
- DeRegistration (unary)
- GetID (unary)
- GetData (server-side streaming): The client expresses interest in getting 
new data whenever data changes, and the server can stream new data as and 
when new data appears.

IIUC right, GetID can take a while for ID allocation to happen, and only 
after that the server can reply to this RPC. And you are concerned if gRPC 
allows the server to block on this call? Yes, the client will pass a 
`context.Context` object in every RPC call, and you are free to set any 
deadline on this context.
On Saturday, August 29, 2020 at 10:09:40 AM UTC-7 sathya...@gmail.com wrote:

> To understand my requirement further let me give an example,
> RPC messages supposed to be sent between in both direction of two gRPC 
> nodes (say A and B)
> RPC messages type1 ->Registration, DeRegsistration and GetData are 
> required to be send from Node A to Node B
> RPC messages type 2 -> GetID and Notification  are initiated from Node B 
> to Node A.
> Here GetID will occur only once during initialisation of application 
> whereas Notification message will be available at random time whenever Data 
> changes occur in Node B
>
> Problem:
> Since gRPC is a client server model, Always it is necessary that client 
> can initiate the request, but in this case RPC message type 2: GetID and 
> Notification are supposed to be initiated from Other side of the channel
> Let me list down two possible solution here
>
>   Solution 1. Application can have two separate channel, one channel 
> for RPC message type 1 to be transferred from NodeA toNode B (n this case 
> NodeA will act as gRPC client and NodeB will act as gRPC Server)and another 
> channel for RPC message type 2 to be transferred from NodeB to NodeA in 
> this case Node A will be gRPC Server and NodeB will be gRPC client. Here 
> both RPC messages types are of unary type.
>
>  Solution 2. Only one channel, in this case Node A will act as Client 
> and Node B will act as Server. RPC message type 1 is of unary rpc type, 
> where as RPC message type 2:Notification can be of server side streaming, 
> where Streaming can happen at any random time whenever Data is available, 
> Here whether gRPC has support to wait for data ,when data available send 
> the response on the wire and again wait for data till application is alive 
> ?? whereas for GetID request single response is enough in this case server 
> supposed to wait for ID Allocation, till then server has to wait for data 
> and response can sent when ID is allocated.
>
> So which among the two solution is best and optimal ??
>

-- 
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/4e873136-3ff6-4152-b53e-395708f24722n%40googlegroups.com.


[grpc-io] Re: How to ensure messages in stream are sent in sequence?

2020-09-16 Thread 'Easwar Swaminathan' via grpc.io
A bidirectional streaming gRPC call is one where the two streams (sending 
and receiving) are totally independent of each other. Messages sent by one 
end will be received by the other end in the order in which it was sent. 
But there can be no guarantees on the order of messages across the streams. 
If you want to impose ordering between the sending and receiving, it has to 
be done at the application layer. For example, instead of sending all five 
messages from one goroutine and reading all responses in another, you could 
use a single goroutine to send and receive messages in order.

On Thursday, August 27, 2020 at 10:58:05 AM UTC-7 yogeswari@gmail.com 
wrote:

>
> I'm calling a bi-directional streaming service with five messages which 
> needs to be sent in sequence.  
> For example pbx.ClientMsg_Sub (Id=3) should be sent and *completed* 
> before pbx.ClientMsg_Set(Id=4).
>
> I notice that if I don't delay the sending of each message, I don't get 
> the expected response. 
> for _, req := range requests {
>fmt.Printf("Sending message: %v\n", req)
>stream.Send(req)
>time.Sleep(500 * time.Millisecond) // doesn't run in sequence 
> if removed
>}
>
> My full code is shared below.
>
> func getUserByCUID(w http.ResponseWriter, req *http.Request) {
>enableCors(&w)
>
> crtFile := "/home/yogesnsamy/Coding/MHub/prod_cert/cert.crt"
>creds, err := credentials.NewClientTLSFromFile(crtFile, "")
>if err != nil {
>log.Fatal("Error loading cert", err)
>}
>
> conn, err := grpc.Dial("dev.mhub.my:16060", grpc.
> WithTransportCredentials(creds))
>if err != nil {
>log.Fatal("Error dialing", err)
>}
>
> c := pbx.NewNodeClient(conn)
>// we create a stream by invoking the client
>stream, err := c.MessageLoop(context.Background())
>if err != nil {
>log.Fatalf("Error while creating stream: %v", err)
>return
>}
>
> // get user's cognito user id
>cuID, ok := req.URL.Query()["cid"]
>
> if !ok || len(cuID[0]) < 1 {
>log.Println("Url Param 'cid' is missing")
>return
>}
>tag := fmt.Sprintf(`"%v"`, cuID[0]) // mhub
>resp := Response{"n/a"}
>
> requests := []*pbx.ClientMsg{
>&pbx.ClientMsg{
>Message: &pbx.ClientMsg_Hi{
>Hi: &pbx.ClientHi{
>Id:"1",
>UserAgent: "Golang_Spider_Bot/3.0",
>Ver:   "0.15",
>Lang:  "EN",
>}},
>},
>&pbx.ClientMsg{
>Message: &pbx.ClientMsg_Login{
>Login: &pbx.ClientLogin{
>Id: "2",
>Scheme: "basic",
>Secret: []byte("carol:carol123"),
>}},
>},
>&pbx.ClientMsg{
>Message: &pbx.ClientMsg_Sub{
>Sub: &pbx.ClientSub{
>Id:"3",
>Topic: "fnd",
>GetQuery: &pbx.GetQuery{
>What: "sub",
>},
>},
>},
>},
>&pbx.ClientMsg{
>Message: &pbx.ClientMsg_Set{
>Set: &pbx.ClientSet{
>Id:"4",
>Topic: "fnd",
>Query: &pbx.SetQuery{
>Desc: &pbx.SetDesc{
>Public: []byte(tag),
>},
>},
>},
>},
>},
>&pbx.ClientMsg{
>Message: &pbx.ClientMsg_Get{
>Get: &pbx.ClientGet{
>Id:"5",
>Topic: "fnd",
>Query: &pbx.GetQuery{
>What: "sub",
>},
>}},
>},
>}
>
> waitc := make(chan struct{})
>// we send a bunch of messages to the client (go routine)
>go func() {
>// function to send a bunch of messages
>for _, req := range requests {
>fmt.Printf("Sending message: %v\n", req)
>stream.Send(req)
>time.Sleep(500 * time.Millisecond) // doesn't run in sequence 
> if removed
>}
>stream.CloseSend()
>}()
>// we receive a bunch of messages from the client (go routine)
>// count := 0
>go func() {
>// function to receive a bunch of messages
>uid := "n/a"
>for {
>res, err := stream.Recv()
>if err == io.EOF {
>resp.TinodeUserID = uid
>js, err := json.Marshal(resp)
>if err != nil {
>http.Error(w, err.Error(), http.
> StatusInternalServerError)
>return
>}
>
> w.Header().Set("Content-Type", "application/json")
>w.Write(js)
>break
>}
>if er

[grpc-io] Re: protobuf build error as Android

2020-09-16 Thread 'sanjay...@google.com' via grpc.io


On Monday, September 7, 2020 at 4:28:31 AM UTC-7 miyuki onuma wrote:

> My app now depends on protobuf-lite and protobuf-javalite, which triggers 
> the multiple class error.


 grpc-java now depends on protobuf-javalite and that seems to conflict 
with  protobuf-lite. Can you remove your dependency on protobuf-lite (may 
be happening indirectly)? 


 

>
> Articles that would be helpful:
> https://stackoverflow.com/questions/62764605/
>
>- The gradle error
>
>
> ```
> > Task :app:minifyProductionReleaseWithR8 FAILED
> /Users/miyuki.onuma/.gradle/caches/transforms-2/files-2.1/0268d94a7c4b3a93962493a637c82377/jetified-protobuf-javalite-3.11.0.jar:
>  
> R8: Type com.google.protobuf.DurationOrBuilder is defined multiple times: 
> /Users/miyuki.onuma/.gradle/caches/transforms-2/files-2.1/0268d94a7c4b3a93962493a637c82377/jetified-protobuf-javalite-3.11.0.jar:com/google/protobuf/DurationOrBuilder.class,
>  
> /Users/miyuki.onuma/vmedia-recorder-android/pb/build/intermediates/runtime_library_classes_jar/release/classes.jar:com/google/protobuf/DurationOrBuilder.class
> ```
>
>
>- My apps build.gradle.
>
> ```
> apply plugin: 'com.android.application'
> apply plugin: 'kotlin-android'
> apply plugin: 'kotlin-android-extensions'
> apply plugin: 'kotlin-kapt'
> apply plugin: 'io.fabric'
> apply plugin: 'com.google.android.gms.oss-licenses-plugin'
>
> android {
> compileSdkVersion rootProject.ext.compilerSdk
> defaultConfig {
> applicationId "com.sample"
> minSdkVersion rootProject.ext.minSdk
> targetSdkVersion rootProject.ext.targetSdk
> versionCode rootProject.ext.versionCode
> versionName rootProject.ext.versionName
> testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
> multiDexEnabled true
> }
>
> configurations {
> implementation.exclude group: 'com.google.protobuf, module: 
> protobuf-lite'
> implementation.exclude group: 'io.grpc, module: grpc-all'
> implementation.exclude group: 'com.google.protobuf, module: 
> protobuf-java'
> implementation.exclude module: 'protolite-well-known-types'
> implementation.exclude module: 'com.google.protobuf'
> }
>
> dataBinding {
> enabled = true
> }
>
> signingConfigs {
> debug {
> storeFile file('debug.keystore')
> storePassword "android"
> keyAlias "androiddebugkey"
> keyPassword "android"
> }
> }
>
> buildTypes {
> debug {
> signingConfig signingConfigs.debug
> versionNameSuffix ".debug"
> }
> release {
> minifyEnabled true
> proguardFiles getDefaultProguardFile('proguard-android.txt'), '
> proguard-rules.pro'
> signingConfig signingConfigs.release
> }
> }
>
> flavorDimensions "default"
>
> compileOptions {
> sourceCompatibility JavaVersion.VERSION_1_8
> targetCompatibility JavaVersion.VERSION_1_8
> }
>
> testOptions {
> unitTests.returnDefaultValues = true
> }
> }
>
> dependencies {
> implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
> implementation 
> "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
> testImplementation 'junit:junit:4.12'
> testImplementation "org.mockito:mockito-core:2.23.0"
> androidTestImplementation "org.mockito:mockito-android:2.21.0"
> androidTestImplementation 'androidx.test:runner:1.3.0'
> androidTestImplementation 'com.android.support.test:rules:1.0.2'
> androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
> testImplementation 
> 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.1'
>
> implementation "androidx.core:core-ktx:${rootProject.ktx}"
> implementation "androidx.annotation:annotation:$rootProject.annotation"
>
> // For view
> implementation "androidx.appcompat:appcompat:$rootProject.appCompat"
> implementation 
> "androidx.constraintlayout:constraintlayout:$rootProject.constraintlayout"
> implementation "androidx.cardview:cardview:$rootProject.cardView"
> implementation 
> "com.google.android.material:material:$rootProject.material"
> 
> implementation("androidx.recyclerview:recyclerview:$rootProject.recyclerView")
>  
> { force = true }
> implementation 
> "de.hdodenhof:circleimageview:$rootProject.circleimageview"
>
> // For network & sync
> implementation 
> "com.google.code.gson:gson:$rootProject.ext.gson_version"
> implementation 
> "com.squareup.okhttp3:okhttp:$rootProject.ext.okhttp_version"
> implementation 
> "com.squareup.okhttp3:logging-interceptor:$rootProject.ext.okhttp_version"
> implementation 
> "com.squareup.retrofit2:retrofit:$rootProject.ext.retrofit2_version"
> implementation 
> "com.squareup.retrofit2:converter-gson:$rootProject.ext.retrofit2_version"
> implementation 
> "com.jakewharton.retrofit:retrofit2-ko

[grpc-io] Re: Help with gRPC Python.

2020-09-16 Thread 'Lidi Zheng' via grpc.io
HI James,

I think we have already discussed this issue 
in https://github.com/grpc/grpc/issues/24018. The proven effective 
workaround is setting an environment variable `GRPC_DNS_RESOLVER=native`. 
The reason why the resolver behaves differently in Ubuntu 20 is still under 
investigation.

Lidi

On Thursday, August 27, 2020 at 1:05:47 PM UTC-7 james.w...@gmail.com wrote:

> I though I may add, if I interupt the client while I am waiting for the 
> response I get:
>
> ```
>   File "greeter_client.py", line 37, in 
> run()
>   File "greeter_client.py", line 31, in run
> response = stub.SayHello(helloworld_pb2.HelloRequest(name='you'))
>   File "/home/james/.local/lib/python3.8/site-packages/grpc/_channel.py", 
> line 824, in __call__
> state, call, = self._blocking(request, timeout, metadata, credentials,
>   File "/home/james/.local/lib/python3.8/site-packages/grpc/_channel.py", 
> line 813, in _blocking
> event = call.next_event()
>   File "src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi", line 338, 
> in grpc._cython.cygrpc.SegregatedCall.next_event
>   File "src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi", line 169, 
> in grpc._cython.cygrpc._next_call_event
>   File "src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi", line 163, 
> in grpc._cython.cygrpc._next_call_event
>   File "src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi", 
> line 63, in grpc._cython.cygrpc._latent_event
>   File "src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi", 
> line 42, in grpc._cython.cygrpc._next
> KeyboardInterrupt
>
> ```
>
> On Thursday, August 27, 2020 at 3:51:31 PM UTC-4 James Spears wrote:
>
>> Hello All, 
>>
>> I am having a very strange issue with running gRPC Python on my Ubuntu 20 
>> machine. 
>>
>> I have created a stack over flow question where I have been trying to 
>> trouble shoot the problem, but I think it requires someone who has specific 
>> knowledge.
>>
>> Please see the stack overflow question here:
>>
>>
>> https://stackoverflow.com/questions/63621097/grpc-python-quickstart-helloworld-greeter-client-py-is-hanging-before-printing
>>
>> Thanks for your time!
>>
>> James
>>
>

-- 
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/9ac23ee4-d65d-42c1-9648-515015036300n%40googlegroups.com.


[grpc-io] Re: [C++] Custom error_message for grpc::Status::OK

2020-09-16 Thread 'Menghan Li' via grpc.io
OK status is not designed to include error messages.

Other options are:
 - Send it in the response
 - Send RPC trailer metadata 
(example: https://github.com/grpc/grpc/tree/master/examples/cpp/metadata)

On Thursday, September 3, 2020 at 3:49:08 AM UTC-7 tnkh...@gmail.com wrote:

> Sometimes, I want to return a Status::OK but with a custom message in 
> error_message(). I cannot extract the error_message in a Status::OK from 
> client. I have to change the server to return some random error like 
> UNKNOWN, OUT_OF_RANGE to read error_message() from the server. 
> tldr; How can I extract error_message() from a StatusCode::OK in client?
>

-- 
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/2900be8f-1c0c-4818-bb1a-526a43c0da56n%40googlegroups.com.


[grpc-io] am I reporting this "Client crashes in Retry" issue in right channel

2020-09-16 Thread li yabo
Hi,

I'm new in this community. Recently I gave a try of grpc retry using 
csharp, ran into this "Client crashes in Retry" issue 
. I provided repro steps, all 
the log I can found, simplified unit test to repro this issue, and what I 
have investigated. While didn't get progress for close to 2 months. Since 
I'm new here, I'm wondering am I reporting this issue in right way using 
right channel? or any suggestion what info I'd provide will be able to help 
code contributors easier understand the issue I'm running into?

Much appreciated if any suggestions!

thanks a lot

-- 
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/53aa3573-e0e1-48c1-b4be-ad07da612908n%40googlegroups.com.