I am opening a websocket ```val client = HttpClien...
# ktor
s
I am opening a websocket
Copy code
val client = HttpClient {
    install(WebSockets) 
}
 client.webSocket( urlString = "<wss://sampleA.com/websocket>") {
        // listen to incoming messages         
 }
Is it possible now to close this websocket and open another one with different url?
Copy code
client.webSocket( urlString = "<wss://sampleB.com/websocket>") {
               
 }
🙂 1
a
You can call the
webSocketSession
method to have a control over the session:
Copy code
val client = HttpClient(CIO) {
    install(WebSockets)
}
val session = client.webSocketSession("<wss://ws.postman-echo.com/raw/>")
// Do something with the session
session.send(Frame.Text("hello"))
session.close()
val session2 = client.webSocketSession("<wss://ws.postman-echo.com/raw/>")
s
Thanks will try it.