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

Server -> Client channel not closed when client is terminated #43

Open
paul-lysak opened this issue Nov 8, 2019 · 0 comments
Open

Server -> Client channel not closed when client is terminated #43

paul-lysak opened this issue Nov 8, 2019 · 0 comments

Comments

@paul-lysak
Copy link

Condition: Some objects are being streamed from the server to the client through the channel
and the client is somehow terminated.

Actual behavior: The channel remains open on the server. If it's unbounded - server may keep writing there until memory ends,
if it's Rendez-Vous channel - it soon gets blocked forever.

Expected behavior: the channel is closed, an exception is thrown if the server tries to write something there.

How to reproduce: take the example code from https://github.com/rouzwawi/grpc-kotlin/tree/master/grpc-kotlin-example-chatserver,
replace the code under the try clause in chat method in ChatService.kt with this to cross out client -> server channel (which is being closed correctly when client shuts down):

                //removed for test
//                for (chatMessage in requests) {
                //added for test
                for (i in 0..100) {
                    //added for test
                    val chatMessage = ChatMessage.newBuilder().setMessage("msg $i").setFrom("TEST").build()
                    println("Got request from $requests:")
                    println(chatMessage)
                    val message = createMessage(chatMessage)
                    clientChannels
                            .filter { it.name != chatMessage.from }
                            .forEach { other ->
                                println("Sending to $other")
                                other.channel.send(message)
                            }
                    //added for test
                    delay(1000)
                }

Build the project and run the server as described in https://github.com/rouzwawi/grpc-kotlin/blob/master/grpc-kotlin-example-chatserver/README.md.
In another terminal run the client as described in the same doc, enter the username. For a while see the test messages being generated - there are logs both in client and server logs.
Terminate the client - see that the server keeps printing "Sending to Client ...".

igor-kovalchuk added a commit to igor-kovalchuk/grpc-kotlin that referenced this issue Dec 18, 2019
…treams (pub-sub pattern) that checks client abandons
igor-kovalchuk added a commit to igor-kovalchuk/grpc-kotlin that referenced this issue Dec 18, 2019
…e kotlin channel when sending message to a client has failed
igor-kovalchuk added a commit to igor-kovalchuk/grpc-kotlin that referenced this issue Dec 18, 2019
igor-kovalchuk added a commit to igor-kovalchuk/grpc-kotlin that referenced this issue Dec 18, 2019
… client unary calls: extend chat.proto, add clientSS, fix README
rouzwawi added a commit that referenced this issue Dec 24, 2019
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

1 participant