Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Constants.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object Consts {
const val releaseGroup = "com.piasy"
const val releaseName = "kmp-socketio"
const val releaseVersion = "1.3.0"
const val releaseVersion = "1.3.1"

val androidNS = "$releaseGroup.${releaseName.replace('-', '.')}"
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ targetSdk = "35"
agp = "8.7.3"
kotlin = "2.1.10"
mockk = "1.13.16"
ktor = "3.1.0"
ktor = "3.2.2"
coroutine = "1.10.1"
compose = "1.7.8"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,8 @@ class DefaultHttpClientFactory(
}
// Linux curl engine doesn't work for simultaneous websocket and http request.
// see https://youtrack.jetbrains.com/issue/KTOR-8259/
// Use two http client could work around it.
private val httpClient: HttpClient = if (!Platform.isLinux) wsClient else httpClient(
trustAllCerts = trustAllCerts,
) {
install(Logging) {
logger = object : Logger {
override fun log(message: String) {
com.piasy.kmp.xlog.Logging.info("Net", message)
}
}
level = LogLevel.ALL
}
install(WebSockets) {
pingIntervalMillis = 20_000
}
}
// But it's fixed in 3.2.0.
private val httpClient: HttpClient = wsClient

override suspend fun createWs(
url: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class ConnectionTestLinux : ConnectionTest() {
}

@Test
fun `simultaneous ws and http request with a single http client will hang`() = doTest {
fun `simultaneous ws and http request with a single http client will also work`() = doTest {
val config: HttpClientConfig<*>.() -> Unit = {
install(io.ktor.client.plugins.logging.Logging) {
logger = object : Logger {
Expand All @@ -110,7 +110,9 @@ class ConnectionTestLinux : ConnectionTest() {
config(this)
}

assertFailsWith<TimeoutCancellationException> {
var pollRes = ""
// ktor 3.2.0 fix the problem
//assertFailsWith<TimeoutCancellationException> {
withContext(Dispatchers.Default) {
withTimeout(5000) {
client.webSocket("ws://localhost:3000/socket.io/?EIO=4&transport=websocket", {}) {
Expand All @@ -126,8 +128,8 @@ class ConnectionTestLinux : ConnectionTest() {
}
Logging.info(TAG, "http response status: ${resp.status}")
if (resp.status.isSuccess()) {
val body = resp.bodyAsText()
Logging.info(TAG, "http response body: $body")
pollRes = resp.bodyAsText()
Logging.info(TAG, "http response body: $pollRes")
break
}
} catch (e: Exception) {
Expand All @@ -138,6 +140,9 @@ class ConnectionTestLinux : ConnectionTest() {
}
}
}
}
//}

val pkt = EngineIO.decodeHttpBatch(pollRes, SocketIO::decode)[0]
assertTrue(pkt is EngineIOPacket.Open)
}
}
Loading