does net/rpc Client possible to do reconnect

907 views
Skip to first unread message

Jarod Liu

unread,
Aug 6, 2013, 8:44:13 AM8/6/13
to golan...@googlegroups.com
when the server stop. the rpc client complains: 
rpc: client protocol error: unexpected EOF

I read the code, this error contain in a internal method input(). the rpc client keep error internal, and not do reconect itself.  how can I reconnect to server, after the server restart.

Andy Bonventre

unread,
Aug 6, 2013, 11:01:38 AM8/6/13
to Jarod Liu, golan...@googlegroups.com
As I understand it, it’s your responsibility to implement reconnect logic that fits your use case. I would venture a guess that the net/rpc authors eschewed reconnect logic because there are too many variables that are dependent on the environment.



--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

liuyu...@gmail.com

unread,
Aug 6, 2013, 11:11:19 AM8/6/13
to Andy Bonventre, golan...@googlegroups.com
I do want to implement it myself. But how can I know the connection lost. 

Andy Bonventre

unread,
Aug 6, 2013, 11:17:16 AM8/6/13
to liuyu...@gmail.com, golan...@googlegroups.com
You can look for the following errors returned by an rpc call...

rpc.ErrShutdown
io.EOF
io.ErrUnexpectedEOF

Those are the ones I’ve encountered in production.

liuyu...@gmail.com

unread,
Aug 6, 2013, 11:28:18 AM8/6/13
to Andy Bonventre, golan...@googlegroups.com
Andy, Thank you for your tips. 
To check these errors on every call sounds like a nightmare.
It would be better if the client can attach a disconnect callback method


在 2013年8月6日星期二,Andy Bonventre 写道:
You can look for the following errors returned by an rpc call...

rpc.ErrShutdown
io.EOF
io.ErrUnexpectedEOF

Those are the ones I’ve encountered in production.


On Tue, Aug 6, 2013 at 11:11 AM, liuyu...@gmail.com <liuyu...@gmail.com> wrote:
I do want to implement it myself. But how can I know the connection lost. 

在 2013年8月6日星期二,Andy Bonventre 写道:

As I understand it, it’s your responsibility to implement reconnect logic that fits your use case. I would venture a guess that the net/rpc authors eschewed reconnect logic because there are too many variables that are dependent on the environment.


On Tue, Aug 6, 2013 at 8:44 AM, Jarod Liu <liuyu...@gmail.com> wrote:
when the server stop. the rpc client complains: 
rpc: client protocol error: unexpected EOF

I read the code, this error contain in a internal method input(). the rpc client keep error internal, and not do reconect itself.  how can I reconnect to server, after the server restart.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 




--
Sent from phone

Sugu Sougoumarane

unread,
Aug 6, 2013, 11:19:10 PM8/6/13
to golan...@googlegroups.com, Andy Bonventre
It's almost always a bad idea to do transparent reconnects at a low level. As your application evolves, you'll be adding custom handshakes like encryption and authentication. Then the feature either becomes a source of bugs, or plain useless.
Reply all
Reply to author
Forward
0 new messages