Thank you for *.end()* on the server, I forgot it. I just want to say that 
it is working in the *nodejs* server. But guys here talking about 
heart-beat and other stuff, I was just curious how to implement it within 
gRPC if it is not supported yet :) Sorry if it was annoying. 

On Saturday, March 4, 2017 at 1:17:32 AM UTC+3:30, Michael Lumish wrote:
>
> I don't understand what the problem is. You say that you get the 'end' 
> event on the server side when the client disconnects. What else do you need?
>
> Also, with streaming calls, you need to call call.end() on the server side 
> too. The callback for the 'end' event is usually a good place to do that.
>
> On Fri, Mar 3, 2017 at 1:38 PM Constantine <[email protected]> wrote:
>
>> I have a *nodejs* server and a *nodejs* client. With a "streaming client 
>> <--> streaming server" when
>>
>>    - I call the *.end()* method on the *client* object, the *.on('end')* 
>> event 
>>    is called on the *server*
>>    - I disconnect the *client* code with *ctrl+c, *also the *.on('end')* 
>> event 
>>    is called on the *server*
>>
>> (I shared my code below.)
>>
>> it means that the server will understand that a client is 
>> dead(disconnected), so there will be no more resource consumption on the 
>> server. Did I miss something or not?
>> I don't know how to implement the heart-beat on this situations, any clue 
>> would be appreciated.
>>
>>
>> *Server.js*
>> var PROTO_PATH = __dirname + '/../../protos/hellostreamingworld.proto';
>>
>> var grpc = require('grpc');
>> var hello_proto = grpc.load(PROTO_PATH).hellostreamingworld;
>>
>> /**
>>  * Implements the SayHello RPC method.
>>  */
>> function sayHello(call) {
>>   call.on('data', () => {
>>     call.write('recieved')
>>   })
>>   call.on('end', () => {
>>     console.log(call.request);
>>   })
>>   console.log("call object is: ", call);
>> }
>>
>> /**
>>  * Starts an RPC server that receives requests for the Greeter service at 
>> the
>>  * sample server port
>>  */
>> function main() {
>>   var server = new grpc.Server();
>>   server.addProtoService(hello_proto.MultiGreeter.service, {sayHello: 
>> sayHello});
>>   server.bind('localhost:50051', grpc.ServerCredentials.createInsecure());
>>   server.start();
>>   console.log('server is running :) ')
>> }
>>
>> main();
>>
>> Client.js
>> var PROTO_PATH = __dirname + '/../../protos/hellostreamingworld.proto';
>>
>> var grpc = require('grpc');
>> var hello_proto = grpc.load(PROTO_PATH).hellostreamingworld;
>>
>> var client = new hello_proto.MultiGreeter('localhost:50051', 
>> grpc.credentials.createInsecure());
>> var user;
>> if (process.argv.length >= 3) {
>>   user = process.argv[2];
>> } else {
>>   user = "world";
>> }
>> call = client.sayHello()
>> call.on('data', (message) => {
>>   console.log("server said: [%s]", message.message);
>> })
>>
>> call.on('end', () => {
>>   console.log("end @ client");
>> })
>>
>> call.write({name: "hadi", num_greetings: "a"})
>> call.write({name: "hadi", num_greetings: "a"})
>> call.end() // you can ommit this and stop the process by ctrl-c. same 
>> behaviour
>>
>>
>> On Saturday, February 25, 2017 at 3:49:59 AM UTC+3:30, [email protected] 
>> wrote:
>>>
>>> Hi all,
>>>
>>> How can I detect in the server side when a client gets disconnected?  
>>> The typical use case could be a chat server where you want to notify other 
>>> users when somebody leaves ungracefully.  
>>>
>>> I haven't been able to find a clear answer to this question yet.    I'm 
>>> using Go implementation.
>>>
>>> Regards,
>>>
>> -- 
>> 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 [email protected].
>> To post to this group, send email to [email protected].
>> 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/1e69ed74-6db4-4d2a-966e-a5302a696dea%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/grpc-io/1e69ed74-6db4-4d2a-966e-a5302a696dea%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/d4efbb84-9f69-40ac-ac36-bc9ddd696f5a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to