[grpc-io] Re: gRPC RPC calls are not working

2018-09-23 Thread qplc
Hi Spencer,

Yes, I have seen it being loaded.
I'm getting below warning.

WARN  [grpc-server-nio-4] - i.n.c.ChannelInitializer - Failed to initialize 
a channel. Closing: [id: 0x2744ef6e, /192.168
.48.162:57068 => /192.168.48.162:50051]
java.lang.NoClassDefFoundError: io/netty/handler/codec/Headers
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at 
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at 
org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2283)
at 
org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:811)
at 
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1260)
at 
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
at 
io.grpc.netty.NettyServerTransport.createHandler(NettyServerTransport.java:221)
at 
io.grpc.netty.NettyServerTransport.start(NettyServerTransport.java:116)
at io.grpc.netty.NettyServer$1.initChannel(NettyServer.java:216)
at 
io.netty.channel.ChannelInitializer.channelRegistered(ChannelInitializer.java:69)
at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRegistered(AbstractChannelHandlerContext.java:133)
at 
io.netty.channel.AbstractChannelHandlerContext.fireChannelRegistered(AbstractChannelHandlerContext.java:119)
at 
io.netty.channel.DefaultChannelPipeline.fireChannelRegistered(DefaultChannelPipeline.java:733)
at 
io.netty.channel.AbstractChannel$AbstractUnsafe.register0(AbstractChannel.java:450)
at 
io.netty.channel.AbstractChannel$AbstractUnsafe.access$100(AbstractChannel.java:378)
at 
io.netty.channel.AbstractChannel$AbstractUnsafe$1.run(AbstractChannel.java:424)
at 
io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:357)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
at 
io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: io.netty.handler.codec.Headers
at 
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1291)
at 
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
... 21 common frames omitted
And it's not working.

On Friday, September 21, 2018 at 3:47:21 PM UTC+5:30, qplc wrote:
>
> Hi,
> I have implemented gRPC in my applications.
> I have created 3 modules:
> Module1: Generate protobuf files
> Module2: Construct gRPC server
> Module3: Construct gRPC client
>
> Here, I'm using zookeeper for the load balancing.
>
> Following dependencies have been added to the module1.
> 
> 
> io.grpc
> grpc-protobuf
> 1.10.0
> 
> 
> io.grpc
> grpc-stub
> 1.10.0
> 
> 
>
> Following dependencies have been added to the module2 and Module3.
> 
> com.google.protobuf
> protobuf-java
> 3.6.1
> 
> 
> io.grpc
> grpc-netty
> 1.10.0
> 
> 
> io.grpc
> grpc-grpclb
> 1.10.0
> jar
> 
>
> On application restart both grpc server and client are being connected to 
> the zookeeper. I can see the grpc server listening on the given port as 
> well.
>
> But, getting below error whenever I'm trying to invoke a rpc.
>
> io.grpc.internal.ManagedChannelImpl$NameResolverListenerImpl$1NamesResolved.run
>  
> [io.grpc.internal.ManagedChannelImpl-1] Unexpected exception from 
> LoadBalancer
>  java.lang.NoClassDefFoundError: io/netty/util/AsciiString
> at 
> io.grpc.netty.NettyClientTransport.(NettyClientTransport.java:111)
> at 
> io.grpc.netty.NettyChannelBuilder$NettyTransportFactory.newClientTransport(NettyChannelBuilder.java:517)
> at 
> io.grpc.internal.CallCredentialsApplyingTransportFactory.newClientTransport(CallCredentialsApplyingTransportFactory.java:49)
> at 
> io.grpc.internal.InternalSubchannel.startNewTransport(InternalSubchannel.java:209)
> at 
> io.grpc.internal.InternalSubchannel.obtainActiveTransport(InternalSubchannel.java:188)
> at 
> io.grpc.internal.ManagedChannelImpl$SubchannelImpl.requestConnection(ManagedChannelImpl.java:1130)
> at 
> io.grpc.util.RoundRobinLoadBalancerFactory$RoundRobinLoadBalancer.handleResolvedAddressGroups(RoundRobinLoadBalancerFactory.java:126)
> at 
> io.grpc.internal.ManagedChannelImpl$NameResolverListenerImpl$1NamesResolved.run(ManagedChannelImpl.java:1032)
> at 

Re: [grpc-io] Re: Are there any good example of grpc in the browser?

2018-09-23 Thread 'Srini Polavarapu' via grpc.io
Greg, a gRPC-web tutorial is in the works 
here https://github.com/grpc/grpc.github.io/pull/737. If you are interested 
please give your feedback in the PR. 

On Thursday, September 20, 2018 at 1:53:06 PM UTC-7, Spencer Fang wrote:
>
> Yes envoy proxy is an example of a supported proxy. gRPC on the web 
> browser uses the grpc-web protocol, which is different from the regular 
> grpc protocol. Here's an example of a config that makes envoy perform this 
> translation: 
> https://github.com/grpc/grpc-experiments/blob/master/grpc-zpages/docker/envoy/zprox.sh
>
>
>
> On Thu, Sep 20, 2018 at 9:27 AM Greg Keys  > wrote:
>
>> By proxy do you mean something like Envoy? I'm not opposed to using 
>> something like that, it's basically serves the same purpose of the router 
>> that I'm used to using from crossbar, so I'm able to reason about that 
>> fairly easily. 
>>
>> I'm also happy to hear the http/2 works with tls, everything we do is 
>> tls. so that should be fine, so long as it will multiplex over a single tcp 
>> connection. the whole reason we're looking to move away from crossbar and 
>> websockets is the scaling issue.
>> We are currently dependent on the crossbar router which does not cluster 
>> or scale making it a single point of failure for us, but envoy appears to 
>> have scaling working quite nicely.
>>
>> I supposed what makes grpc-web so hard to reason about at the moment is 
>> the documentation, it's not very clear, the documentation lays out a simple 
>> Echo, EchoRequest, EchoResponse proto but in the actual code they implement 
>> about 20 other methods, addLeft, addRight etc. so my mind immediately 
>> goes wtf.
>>
>> I guess I'll spend a little more time sorting through the code and try to 
>> come up with something simpler to digest, grpc-web examples are definitely 
>> lacking right now.
>>
>> On Wednesday, September 19, 2018 at 6:15:54 PM UTC-7, Carl Mastrangelo 
>> wrote:
>>>
>>> There are examples how to run in a browser, but they typically involve a 
>>> sidecar proxy.  Here is one example: 
>>> https://github.com/grpc/grpc-experiments/tree/master/grpc-zpages   The 
>>> full docs are here: https://github.com/grpc/grpc-web
>>>
>>> Browsers present two challenges to gRPC.  First, they only use HTTP/2 
>>> when using TLS or SSL, which a lot of websites don't.   Second, Browsers 
>>> don't expose the HTTP trailers that are needed to tell when the response is 
>>> done.  To get around these issues, we have gRPC-Web protocol, which 
>>> modifies the gRPC protocol slightly to be usable on HTTP/1.1.  The fetch() 
>>> API for Browsers was supposed to fix the latter problem, but it has not 
>>> been implemented by them, so we are kinda stuck with the work around until 
>>> they do.  
>>>
>>> Lastly, browsers use CORS when making RPCs across origin, which happens 
>>> when you serve your RPCs from a different port than you HTML.  This may 
>>> affect you depending on your setup.
>>>
>>>
>>> I guess all of this is to say that getting requests (or RPCs) to work in 
>>> the browser is much more complicated that it first appears, and 
>>> unfortunately we can't fix it for you.  The proxy solution, while more 
>>> complex, does solve a number of things you would have to otherwise do.
>>>
>>>
>>>
>>>
>>>
>>> On Wednesday, September 19, 2018 at 4:26:57 PM UTC-7, Greg Keys wrote:

 I was thrilled when I started looking at gRPC as an alternative to our 
 current implementation of websockets (crossbar.io) however that 
 enthusiasm is dwindling the more I look into it.

 Am I understanding this correctly that it's primary strength is server 
 side service to service communication? 

 My hope was to use it in the browser as well as service to service. But 
 from what I gather the browser implementation is still using http/1.1 and 
 it does not multiplex as a result and instead uses xhr

 I have not been able to find any good (simple) examples of gRPC in the 
 browser, I've found a couple but they are really complex to reason about, 
 compared to the server side examples which are
 typically really simple.

 Are there any good examples of gRPC in the browser? are there any 
 implementations in the browser that multiplex?

>>> -- 
>> 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+u...@googlegroups.com .
>> To post to this group, send email to grp...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/grpc-io.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/grpc-io/e31b7f17-70e8-4a53-bec4-055eca05c9d9%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit