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

Conflict between WebSockets and StatusPages #889

Closed
neworld opened this issue Jan 20, 2019 · 2 comments
Closed

Conflict between WebSockets and StatusPages #889

neworld opened this issue Jan 20, 2019 · 2 comments
Assignees
Labels
Milestone

Comments

@neworld
Copy link

neworld commented Jan 20, 2019

Following test just hangs. This issue could be similar to #745.

    @Test
    fun testConversation() {
        withTestApplication {
            application.install(WebSockets)
            application.install(StatusPages) // <-- I added only this

            val received = arrayListOf<String>()
            application.routing {
                webSocket("/echo") {
                    try {
                        while (true) {
                            val text = (incoming.receive() as Frame.Text).readText()
                            received += text
                            outgoing.send(Frame.Text(text))
                        }
                    } catch (e: ClosedReceiveChannelException) {
                        // Do nothing!
                    } catch (e: Throwable) {
                        e.printStackTrace()
                    }
                }
            }

            handleWebSocketConversation("/echo") { incoming, outgoing ->
                val textMessages = listOf("HELLO", "WORLD")
                for (msg in textMessages) {
                    outgoing.send(Frame.Text(msg))
                    assertEquals(msg, (incoming.receive() as Frame.Text).readText())
                }
                assertEquals(textMessages, received)
            }
        }
    }

Versions

  • Ktor: 1.1.1
  • Java: openJDK 11.0.1
  • Kotlin: 1.3.11
  • Coroutines: 1.1.0

Ktor Engine Used(client or server and name)

Test engine.

Thread dump

"Test worker" #13 prio=5 os_prio=0 cpu=355.78ms elapsed=20.86s tid=0x00007f9344b56000 nid=0x5c4c waiting on condition  [0x00007f92ff095000]
   java.lang.Thread.State: WAITING (parking)
        at jdk.internal.misc.Unsafe.park([email protected]/Native Method)
        - parking to wait for  <0x000000062dd27610> (a java.util.concurrent.CompletableFuture$Signaller)
        at java.util.concurrent.locks.LockSupport.park([email protected]/LockSupport.java:194)
        at java.util.concurrent.CompletableFuture$Signaller.block([email protected]/CompletableFuture.java:1796)
        at java.util.concurrent.ForkJoinPool.managedBlock([email protected]/ForkJoinPool.java:3128)
        at java.util.concurrent.CompletableFuture.waitingGet([email protected]/CompletableFuture.java:1823)
        at java.util.concurrent.CompletableFuture.join([email protected]/CompletableFuture.java:2043)
        at io.ktor.server.testing.TestApplicationEngine.handleWebSocket(TestApplicationEngine.kt:145)
        at io.ktor.server.testing.TestApplicationEngine.handleWebSocketConversation(TestApplicationEngine.kt:160)
        at io.ktor.server.testing.TestApplicationEngine.handleWebSocketConversation$default(TestApplicationEngine.kt:156)
        at com.neworldwar.backend.controller.ChatControllerTest$testConversation$1.invoke(ChatControllerTest.kt:57)

Full: https://gist.github.com/neworld/ffb5e2792870b6b4c7b72e7d70d8ba57

@cy6erGn0m cy6erGn0m self-assigned this Jan 21, 2019
@cy6erGn0m
Copy link
Contributor

cy6erGn0m commented Jan 21, 2019

This seems to be fixed in the master but I can reproduce it with 1.1.1 . Not exactly clear how it is fixed yet.

@cy6erGn0m cy6erGn0m added this to the 1.1.2 milestone Jan 21, 2019
@cy6erGn0m cy6erGn0m added the bug label Jan 21, 2019
@cy6erGn0m
Copy link
Contributor

Fixed.

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

No branches or pull requests

2 participants