https://kotlinlang.org logo
Title
k

Kirill Prybylsky

05/10/2020, 11:58 AM
Hello everyone, I am trying to implement websocket feature with ktor, but I only get 404 for the http://localhost:8080/ request in browser. Could you, please, tell me what can be wrong? Here is my websocket implementation:
webSocket("/") {
    while (true) {
        delay(3000)
        outgoing.send(Frame.Text("hi"))
    }
}
f

Foso

05/10/2020, 12:52 PM
did you "installed" WebSockets?
install(WebSockets)
k

Kirill Prybylsky

05/10/2020, 12:52 PM
@Foso of course 🙂
f

Foso

05/10/2020, 12:57 PM
okay, try to connect to ws://localhost:8080/
k

Kirill Prybylsky

05/10/2020, 12:59 PM
@Foso I had relaunch server and tried to connect but..
install(WebSockets){
    pingPeriod = Duration.ofSeconds(60)
    timeout = Duration.ofSeconds(15)
    maxFrameSize = Long.MAX_VALUE
    masking = false
}
install setup
f

Foso

05/10/2020, 1:02 PM
i meant in your websocket client where you connect to your websocket
k

Kirill Prybylsky

05/10/2020, 1:03 PM
my client is a web browser, i also tried with chrome extension but result the same
f

Foso

05/10/2020, 1:12 PM
okay, then i don't know a quick solution, try to check in the debugger if there is an incoming connection for your websocket. Maybe you should also post your question in #ktor
a

alex j

05/10/2020, 4:02 PM
should i be concerned? 🤔
f

Foso

05/10/2020, 4:07 PM
I don't know why it needs that permission, but you can also get it from here: https://github.com/hakobera/Simple-WebSocket-Client
j

Jeremy Rouet

05/10/2020, 11:47 PM
when you need to access to the tabs, unfortunaly chrome ask this permissions 😞
I don't know why and i have the same problem in my chrome extention