Answers inline 

On Tuesday, August 2, 2016 at 2:30:20 PM UTC-7, nevil...@gmail.com wrote:
>
> Hi everyone,
>
> I'm migrating an Android app from a REST endpoint to gRPC, and so far 
> things are going well. I just have a few questions on some aspects that I'm 
> unsure of, I hope that someone can help me out.
>
>
>    1. Should I be making RPC calls on the main thread? I've been doing 
>    that so far with blocking stubs, and performance is good, but sometimes 
> the 
>    main thread gets infinitely frozen. I don't know if I'm perhaps not 
>    handling errors properly.
>
> If you are using the blocking stubs, then no you should not make calls 
from the main thread.  Under the hood, gRPC will run your requests on the 
network threads, and an application provided Executor.  (or a  default, if 
you don't set one).  However, waiting for the RPC to finish would still 
happen from the main thread.  You can use the Future API if you would like 
a nice way of handling the response from a different thread.  Note that 
RPCs will not time out if you don't provide a deadline.  You can use 
stub.withDeadline() to set one.
 

>
>    1. I've so far been initialising a new stub/connection on every 
>    activity/fragment, would this mean that multiple HTTP connections are 
> open? 
>    Would initialising a single stub in my Application be a better solution? I 
>    just haven't tried it out as I don't know how I'd tell if there's a 
>    difference.
>
> Yes.  You should create just one stub and let it handle the connections. 
 It will automatically create and release connections as needed.  Stubs 
should be safe to use by multiple places. 


>    1. I'm using Node.js as my server, and so far I've struggled with 
>    using an async connection, I've looked at the examples a few times, but 
> I'm 
>    still struggling. Is there anyone who can point me to other resources on 
>    the net? Unfortunately for me, most people using gRPC in public/GitHub are 
>    using the golang version. 
>
> Thanks in advance
>
> Neville
>

-- 
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 post to this group, send email to grpc-io@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/29b07c91-53a9-4fe6-8ddb-11d43d452fef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to