-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
When having ktor implemented in the app. PowerSync won't sync as it gets a timeout error thrown.
Tried with ktor version 3.3.0 and 3.2.3 (which is the same version as used in the library)
15:53:53.680 PowerSync E Error in streamingSync: Software caused connection abort
15:53:58.791 PowerSync E Error in streamingSync: Unable to resolve host "your domain": No address associated with hostname
When I removed
// Network
implementation(libs.ktor.client.android)
implementation(libs.ktor.client.content.negotiation)
implementation(libs.ktor.client.logging)
implementation(libs.ktor.serialization.kotlinx.json)
from build.gradle.kts
And used a OkHttpClient in PowerSyncBackendConnector everything works fine.
Example PowerSyncBackendConnector, same code fails with ktor implementation in gradle files. It doesn't even have to be in use:
class PSConnector() : PowerSyncBackendConnector() {
private val httpClient = OkHttpClient()
override suspend fun fetchCredentials(): PowerSyncCredentials? {
val baseUrl = "base url";
return try {
val requestBody = "{}".toRequestBody("application/json".toMediaType())
val request = Request.Builder()
.url("${baseUrl}/api/powersync/auth") //Our custom auth endpoint
.post(requestBody)
.build()
httpClient.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
return null
}
val responseBody = response.body?.string() ?: return null
val jsonObject = JSONObject(responseBody)
val token = jsonObject.getString("token")
PowerSyncCredentials(
endpoint = "${baseUrl}/sync", //sync is necessary for our be setup. Thats not the problem ;)
token = token
)
}
} catch (e: Exception) {
null
}
}
override suspend fun uploadData(database: PowerSyncDatabase) {
}
}
Metadata
Metadata
Assignees
Labels
No labels