...
This commit is contained in:
parent
c5bc3f9bf0
commit
1552020d31
@ -10,6 +10,10 @@ import io.ktor.client.plugins.websocket.*
|
||||
import io.ktor.client.engine.cio.*
|
||||
import io.ktor.client.engine.okhttp.*
|
||||
import io.ktor.client.plugins.*
|
||||
import io.ktor.client.plugins.logging.DEFAULT
|
||||
import io.ktor.client.plugins.logging.LogLevel
|
||||
import io.ktor.client.plugins.logging.Logger
|
||||
import io.ktor.client.plugins.logging.Logging
|
||||
import io.ktor.http.*
|
||||
import io.ktor.websocket.*
|
||||
import kotlinx.coroutines.*
|
||||
@ -32,6 +36,11 @@ object KisWebSocketManager {
|
||||
install(WebSockets) {
|
||||
pingInterval = 20_000
|
||||
}
|
||||
install(Logging) {
|
||||
logger = Logger.DEFAULT
|
||||
level = LogLevel.ALL // ALL, HEADERS, BODY, INFO, NONE 중 선택
|
||||
}
|
||||
|
||||
install(HttpTimeout) {
|
||||
requestTimeoutMillis = 30_000 // 전체 요청 시간
|
||||
connectTimeoutMillis = 10_000 // 서버 연결 시간
|
||||
@ -78,6 +87,7 @@ object KisWebSocketManager {
|
||||
while (isActive) { // 재연결을 위한 루프 추가
|
||||
try {
|
||||
client.webSocket(method = HttpMethod.Get, host = url.split(":")[0], port = url.split(":")[1].toInt(), path = "/last_price") {
|
||||
println("✅ 웹소켓 세션 진입 성공")
|
||||
session = this
|
||||
isConnected.set(true)
|
||||
println("✅ 웹소켓 연결 성공")
|
||||
@ -102,7 +112,9 @@ object KisWebSocketManager {
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
println("❌ 웹소켓 연결 끊김: ${e.message}")
|
||||
e.printStackTrace()
|
||||
} finally {
|
||||
println("🏁 웹소켓 finally 블록 진입 (연결 시도 종료)")
|
||||
isConnected.set(false)
|
||||
session = null
|
||||
println("⏳ 5초 후 재연결 시도...")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user