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

Example of server stream subscription #81

Open
AliceCarroll239 opened this issue Oct 17, 2019 · 4 comments
Open

Example of server stream subscription #81

AliceCarroll239 opened this issue Oct 17, 2019 · 4 comments

Comments

@AliceCarroll239
Copy link

AliceCarroll239 commented Oct 17, 2019

Hello

Can you provide an example of how to subscribe to a server stream please?
In my case, the server sends messages to the stream every second, but when I connect to it like:
Screenshot at Oct 17 17-13-11

I get messages every 1-2 minutes.

@marcoferrer
Copy link
Owner

That’s a bit odd. I can’t immediately tell what your issue might be. Do you have snippet or example of what your server side imple looks like for this endpoint?

@marcoferrer
Copy link
Owner

marcoferrer commented Oct 17, 2019

In the example project there is a sample of a ticker service. This might help some but if you’re still having issues I’m happy to help. A key thing to note is that this example binds a single producer broadcasting to multiple clients. Which might be the same as your use case.

https://github.com/marcoferrer/kroto-plus/blob/master/example-project/src/main/kotlin/krotoplus/example/MultipleClientSubscriptionsExample.kt

For a one to one service to client impl something like this might be what you're looking for.

    override suspend fun listen(request: Empty, responseChannel: SendChannel<Tick>) {
        while(isActive){
             responseChannel.send(...)
             delay(1000)
        }
    }

@AliceCarroll239
Copy link
Author

I can give the following example

In the golang, I just wrap the method in a FOR loop and get the following (this is what I need)
GoExample
In kotlin I get the following output (and I don’t get into the loop, the output comes from the consumeEach method once every 1 minute)
KotlinExample

My question is how your library implement similar behavior
Maintain a connection to the stream and get values ​​from it constantly

@marcoferrer
Copy link
Owner

So my current best guess is that in someway the behavior of the flow control implemented in grpc go differs from the java impl. If thats the case, this would be an interop bug that should be fixed in kroto. Ill need to get a sample project together to reproduce the issue, but after that I should be able to track down the source of the problem. Thanks again for reporting this!

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

No branches or pull requests

2 participants