grpc-go icon indicating copy to clipboard operation
grpc-go copied to clipboard

Send GOAWAY on client shutdown

Open ejona86 opened this issue 9 years ago • 12 comments

The HTTP/2 spec encourages sending GOAWAY before dropping the connection. GOAWAY is necessary for "graceful" shutdowns.

When error handling:

Endpoints SHOULD send a GOAWAY frame when ending a connection, providing that circumstances permit it.

In the GOAWAY frame description section:

Endpoints SHOULD always send a GOAWAY frame before closing a connection so that the remote peer can know whether a stream has been partially processed or not.

.

A GOAWAY frame might not immediately precede closing of the connection; a receiver of a GOAWAY that has no more use for the connection SHOULD still send a GOAWAY frame before terminating the connection.

When discussing connection management:

When either endpoint chooses to close the transport-layer TCP connection, the terminating endpoint SHOULD first send a GOAWAY (Section 6.8) frame so that both endpoints can reliably determine whether previously sent frames have been processed and gracefully complete or terminate any necessary remaining tasks.

ejona86 avatar Dec 04 '15 01:12 ejona86

Dupe of #147.

dsymonds avatar Dec 04 '15 01:12 dsymonds

#147 is server-side, this is client-side.

ejona86 avatar Dec 04 '15 01:12 ejona86

Any update on this?

pires avatar Dec 30 '15 18:12 pires

+1, currently seems there's no way to close a clientconn gracefully, the transport is not accessible from outside of clientconn, so it's not possible to send Goaway to the transport

shuaichang avatar Feb 08 '18 19:02 shuaichang

@shuaichang is the current behavior causing problems for you? IIUC, this is a pretty minor issue in that it would allow the server to more quickly clean up when a client disconnects, but is not a high priority issue.

Maybe you're more interested in #1104?

dfawley avatar Feb 08 '18 22:02 dfawley

We implemented a client conn cache and sometime need to evict some conn out of cache and close it, without a graceful Close method, we will have implement something based on timeout, which is sub-optimal comparing to the grpc transport.GracefulClose. Seems the function is there, but not exported out of the package

shuaichang avatar Feb 08 '18 22:02 shuaichang

@shuaichang thanks for the explanation. That feature request is #1104, not this issue. This issue is about sending an HTTP2 GOAWAY frame before closing a connection, regardless of whether we allow existing streams on that connection to continue.

dfawley avatar Feb 08 '18 23:02 dfawley

Cool, I'll +1 in that issue

shuaichang avatar Feb 08 '18 23:02 shuaichang

Hi, I'd like to take a shot at it if its already not done. I'm new at go and learning. is it done?

dv29 avatar Jan 07 '20 18:01 dv29

No, this is not done. Feel free to send a PR or let us know if you have questions. Thanks!

dfawley avatar Jan 07 '20 21:01 dfawley

Sorry for delayed reply, I'll get on it.

dv29 avatar Jan 28 '20 20:01 dv29

Hi I'd be interested in resolving this issue.

aranjans avatar Feb 16 '24 03:02 aranjans