hyperium / tonic

A native gRPC client & server implementation with async/await support.
https://docs.rs/tonic
MIT License
9.88k stars 1.01k forks source link

Detect UDS client disconnection #1249

Open Jackbaude opened 1 year ago

Jackbaude commented 1 year ago

Feature Request

Motivation

We have a UDS server that looks for DHCP leases for a client. When the client disconnects we would like to be able to recognize this and stop DORA on the server side - otherwise the server just keeps searching for a lease. It would be useful in this case to recognize that the client disconnected and that we can do clean up on the server side.

I understand this issue has been talked about before in issue number #377, however, that was related to streamed connections.

Proposal

Im unsure of how this would be implemented. I do think having some sort of channel which sends messages about disconnected clients which would give specific information on which client disconnected would be helpful.

baude commented 1 year ago

bump. does anyone have information about this?

LucioFranco commented 1 year ago

Without using streaming currently the server doesn't support this. You could work around this by implementing your own connection type that uses drop to do clean up. Though you would have to use hyper manually and not use the tonic transport since this isn't a feature that comes out of the box.

Jackbaude commented 1 year ago

@LucioFranco Can you explain what you mean by

Though you would have to use hyper manually and not use the tonic transport since this isn't a feature that comes out of the box.

Can you guide me in the right direction for how to do this?

Additionally if we were to use streaming, how could we detect disconnection if we only need to send one request. In other words the client just needs to send a config over to the server once, and the server needs to process the config for a lease but also watch to see that the client didnt drop before. Thank you for any help!

LucioFranco commented 1 year ago

@Jackbaude There should be a uds example that newtypes the connection and you can use that and implement drop to send a message.

You can always add a separate streaming request/response that you use to detect disconnection. Then you have your regular unary request that does the other work.