Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to expose stream state to the app? It's vital for tracking http2 requests and make appropriate reconnect logic etc.... #706

Open
vhunkalo opened this issue Apr 29, 2024 · 19 comments

Comments

@vhunkalo
Copy link

https://github.com/dart-lang/http2/blob/master/lib/src/streams/stream_handler.dart

attached link to the code, how to expose StreamState?

@vhunkalo
Copy link
Author

@aran
Copy link
Contributor

aran commented Apr 29, 2024

I'm sorry, I'm not sure how to help.

AFAIK this repository is in maintenance mode, so I'm not sure what might move this issue forward for you. Normally I'd advise elaborating more—what's your specific question, what have you tried so far, what are you trying to achieve big picture, is there example code you'd like to be able to write that you can't, etc.

@vhunkalo
Copy link
Author

I'm using Dart gRPC and I need to intercept some specific call(sync bi-directional stream) and it's essential to know its status(ready/close etc...), without it, it's impossible to make some reconnect logic etc

@vhunkalo
Copy link
Author

without it, I don't know exact moment when stream is ready or not, when it's broken for example due to the Internet switch from Wi-Fi to Celluar, and it's implemented but StreamState is private and it's impossible to use it, why?
In Kotlin it's implemented perfectly and work perfect

@vhunkalo
Copy link
Author

vhunkalo commented Apr 29, 2024

IMAGE 2024-04-29 21:47:24
StreamState is hidden,but it's essential data to be exposed for dev

@vhunkalo
Copy link
Author

vhunkalo commented Apr 29, 2024

so the question, how with grpc library I can access http2 requests and track them in more detail to robust reconnecting/requests dequeuing etc... @aran

@aran
Copy link
Contributor

aran commented Apr 29, 2024

I'm sorry, I don't know the answer. (I'm also not a maintainer of this repo).

@vhunkalo
Copy link
Author

@mraleph could you please check this issue?

@mraleph
Copy link
Member

mraleph commented Apr 30, 2024

Do you really need StreamState? What code would you write if you had access to that?

It has all this very specific information about the state of a specific HTTP/2 stream, rather than the state of the whole HTTP/2 connection. I am not sure I understand what it has to do with reconnect on network changes - it would seem you need to just track health of the whole connection.

@vhunkalo
Copy link
Author

For example, I have bi-directional stream inside my gRPC channel, it is configured in the server to live only 15sec and then I need to reconnect, and I need to track state of my rpc call(stream) in more robust way having all states of this call, because now I don't have any info regarding this stream, whether it's live or not @mraleph

@vhunkalo
Copy link
Author

@mraleph yes yes, I need information about specific HTTP2 stream inside of gRPC

@vhunkalo
Copy link
Author

this stream is using for messages in chat app, it need a lot of reconnection/requests dequeueing etc..., so I need to know health of this specific stream to handle it appropriately, it's vital info and without it it's impossible to develop reliable chat app bacause health of the stream is hidden and impossible to expose it

could fork lib and adjust it by myself, but it's not good idea if lib could have ability to intercept specific calls in more detail

@vhunkalo
Copy link
Author

vhunkalo commented Apr 30, 2024

so yes, I need to track health of specific HTTP2 stream inside gRPC channel, NOT whole channel

@vhunkalo
Copy link
Author

vhunkalo commented Apr 30, 2024

so regarding the code @mraleph

if (stream.state == StreamState.ready) { requestStreeamController.add(request); } else if(stream.state == StreamState.terminated){reconnect();}

@vhunkalo
Copy link
Author

@mraleph quick question, is it possible to adjust this thing in the gRPC library to make such info accessible for developers?

@mraleph
Copy link
Member

mraleph commented Apr 30, 2024

I honestly don't know and I don't have any time to look into this. At this point you are better off forking and patching things in the way that makes it work for you.

@vkammerer
Copy link

We're evaluating gRPC for our flutter apps, and find it hard to find guidance and recommandations about how to implement it. One topic that seems to require attention is reconnection logic.

@aran you wrote

AFAIK this repository is in maintenance mode

Does that mean that grpc-dart is not the recommended / optimal way of implementing gRPC for mobile flutter clients? Is there another way to implement a gRPC client that would be robust, resilient, and able to talk to a Flutter app?

@mosuem
Copy link
Contributor

mosuem commented Jun 5, 2024

I don't know what "maintenance mode" means exactly - it is maintained, if that is what it means. But there are no plans on adding new features, as the library is in a good state as is.
For usage on grpc in general, I would advise the docs. For help on specific implementations, forums like stackoverflow.com might be a good place to get help.

@aran
Copy link
Contributor

aran commented Jun 5, 2024

@mosuem that is exactly what I meant by maintenance mode. I apologize if that came across in a negative manner.

@vkammerer I can't speak to "the recommended" but I'm using this library for a Flutter app and it works so far and I don't think there's another realistic way to use grpc with a Flutter app.

The real trade is grpc vs. something else like hand-coded json or openapi. In particular, if you are targeting the web platform, caveats to grpc-web are that by default you lose being able to look at your data in web inspector without an additional browser plugin & configuration, and grpc-web doesn't support client streaming and bidirectional streams (and won't at least until Safari ships WebTransport).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants