question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Detecting abrupt stream closing in C++ client library

See original GitHub issue

Description Not exactly a bug, but I needed some clarifications regarding the C++ triton client API.

Triton Information What version of Triton are you using? 21.08

Are you using the Triton container or did you build it yourself? Container

To Reproduce

Pseudocode-ish example

InferenceServerGrpcClient::Create(&triton_client, url_, /*verbose*/ false);
triton_client->StartStream([&](tc::InferResult *result) {
   if (detect_end_of_stream(result)) atomic_global_bool.set(thread_done);
}

Here, the constructor for the inference server client internally creates a new thread that constantly receives data from the server https://github.com/triton-inference-server/client/blob/main/src/c%2B%2B/library/grpc_client.cc#L1530

Now the callback is invoked by the thread on receiving data, and the callback knows that it’s finished by identifying that the recived data corresponds to the end of a stream.

However, in the case that the server crashes for some reason, the thread simply exits without any indication whatsoever (// End loop if Read() returns false)

In my case, the callback sets a global boolean that the main thread polls to know when the data is ready to be used. But if the server abrubtly dies, the client library doesn’t inform that the thread has actually exited, which leads to a deadlock since the callback doesn’t get called.

So am I missing something obvious or should there be something like a FinishCallback invoked here? https://github.com/triton-inference-server/client/blob/main/src/c%2B%2B/library/grpc_client.cc#L1573

Expected behavior The library should have some mechanism to communicate connection disruption

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jbkyang-nvicommented, Dec 14, 2022

The client does not such a functionality. Like I said ClientReaderWriter does not have API that can call isFinished() or onFinishedCallback() even though we can close it through Finish(). It seems like IsServerLive is something you can call to break out of the loop (as a part of the callback), or you can set a timeout on the AsyncStreamInfer() request to stop the deadlock

0reactions
git-bruhcommented, Dec 14, 2022

Alright, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Detecting TCP Client Disconnect - c++ - Stack Overflow
In TCP there is only one way to detect an orderly disconnect, and that is by getting zero as a return value from...
Read more >
TCP Connection Termination - GeeksforGeeks
In an Abrupt connection release, either one TCP entity is forced to close the connection or one user closes both directions of data...
Read more >
Wolf Gupta git-bruh - GitHub
Detecting abrupt stream closing in C++ client library. Description Not exactly a bug, but I needed some clarifications regarding the C++ triton client...
Read more >
Connection - Ably Realtime
If a reply is not received from Ably within a short period of time, the connection will be forcibly terminated and the connection...
Read more >
No exception thrown to server when streaming RPC client ...
I've implemented a simple streaming RPC service and am having a problem closing down the stream server side due to a lack of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found