Jeff
06/10/2021, 9:14 AM6371 * ACOS(COS(RADIANS(:latitude)) * COS(RADIANS(`lat`)) * COS(RADIANS(:longitude) - RADIANS(`lng`)) + SIN(RADIANS(:latitude)) * SIN(RADIANS(`lat`))) AS `distance`
Anyone with an idea on how to implement this?ms
06/10/2021, 10:03 AMAnkit Dubey
06/11/2021, 4:31 AMSLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
This error doesn’t come when i pass HashMap<String, String> to body
But whenever i’m passing, HashMap<String, Any>
then only getting error.
Any idea? Do I need to add SLF4J dependency🤔tim
06/11/2021, 11:40 AMCLOVIS
06/12/2021, 1:35 PMJsonSupport.kt:54
useArrayPolymorphism = true
Ktor 1.6.0 client-side, KotlinxSerializer.kt:64
useArrayPolymorphism = false
Where should I report that? GitHub, YouTrack?divyanshunegi
06/12/2021, 5:33 PMKtor
Implementation.
• It should have local SSL data encryption
• InternetConnectionCheck Interceptor
• ErrorHandlerInterceptor
• RetryRequest After RefreshToken Interceptor
• Few other custom interceptors
Earlier I was writing my APiClient in the commonMain
but as I can see it does not support addInterceptor property by default, which is available in OkHttp for Android.
So the new plan I had is create an expect class APiClient in common main and implement APIClient for Android on AndroidMain with OkHttp engine and APiClient on iOSMain with IOS Engine.
Is this approach right ? or am I missing some part ?tylerwilson
06/14/2021, 3:48 PMPavel Petkevich
06/14/2021, 7:14 PMMBegemot
06/15/2021, 4:42 PMMichal Klimczak
06/16/2021, 7:36 AMjava.net.SocketException: Software caused connection abort
(thread)Rak
06/16/2021, 11:06 AMval customer: Customer = client.get("<http://127.0.0.1:8080/customer>")
My question is how can I then get the response headers?natario1
06/16/2021, 11:07 AMWWW-Authenticate
on 401, so the Auth plugin is not working properly. I have tried with:
client.receivePipeline.intercept(HttpReceivePipeline.Before) { response ->
if (response.status == HttpStatusCode.Unauthorized && !response.headers.contains(HttpHeaders.WWWAuthenticate)) {
val headers = buildHeaders {
appendAll(response.headers)
append(HttpHeaders.WWWAuthenticate, "Bearer")
}
proceedWith(object : HttpResponse() {
override val headers get() = headers
// delegate all other properties to original response
})
} else {
proceed()
}
}
And I can see with the debugger that this is invoked before the header check in Ktor's Auth
class. But still, the response passed to Auth does not include my header. It seems like the response passed to proceedWith()
does not replace call.response
, which is what Auth plugin reads. Any idea?Jgafner
06/16/2021, 12:51 PMgenerateJks
task in the docs can be improve by setting the output of the task:
I did something like this:
tasks.register("generateJks", JavaExec::class) {
dependsOn("classes")
group = "certificate"
classpath = sourceSets["main"].runtimeClasspath
outputs.dir("${project.buildDir}/certs/")
mainClass.set("com.my.main.Class")
}
and changed the object and the conf file:
val jksFile = File("build/certs/temporary.jks").apply {
parentFile.mkdirs()
}
natario1
06/16/2021, 2:17 PMbearer.refreshTokens { }
when using the Auth plugin? I'm trying to hit server from there using the same client that initiated the failed request, but I get a deadlock with both requests stuck. If I use a different HttpClient
only inside refreshTokens { }
, everything works fine 😕elye
06/17/2021, 2:49 PMAndrew Steinmetz
06/19/2021, 5:45 PMTim Malseed
06/20/2021, 12:34 PMFile("./srv/emails.txt")
The file is located at project_root/srv/emails.txt
. But I get a FileNotFoundException
when I call readLines
on the filedarkmoon_uk
06/20/2021, 12:59 PMFlow
of (serialized) objects i.e. delivered by HTTP streaming?Voronin Sergey
06/21/2021, 8:57 AMSourabh Rawat
06/22/2021, 10:55 AMAleksandr Ivanov
06/24/2021, 6:55 AMUncaught Kotlin exception: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen kotlinx.coroutines.JobImpl@2516528
at 0 DriversAppApi 0x000000010155103f kfun:kotlin.Throwable#<init>(kotlin.String?){} + 95 (/Users/teamcity3/buildAgent/work/290aee0e088a1666/runtime/src/main/kotlin/kotlin/Throwable.kt:23:37)
at 1 DriversAppApi 0x00000001015497ad kfun:kotlin.Exception#<init>(kotlin.String?){} + 93 (/Users/teamcity3/buildAgent/work/290aee0e088a1666/runtime/src/main/kotlin/kotlin/Exceptions.kt:23:44)
at 2 DriversAppApi 0x0000000101549a1d kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 93 (/Users/teamcity3/buildAgent/work/290aee0e088a1666/runtime/src/main/kotlin/kotlin/Exceptions.kt:34:44)
at 3 DriversAppApi 0x00000001015819fd kfun:kotlin.native.concurrent.InvalidMutabilityException#<init>(kotlin.String){} + 93 (/Users/teamcity3/buildAgent/work/290aee0e088a1666/runtime/src/main/kotlin/kotlin/native/concurrent/Freezing.kt:22:60)
at 4 DriversAppApi 0x0000000101581dcf ThrowInvalidMutabilityException + 431 (/Users/teamcity3/buildAgent/work/290aee0e088a1666/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt:93:11)
at 5 DriversAppApi 0x00000001016e5b50 MutationCheck + 128
at 6 DriversAppApi 0x00000001017ebda6 kfun:kotlinx.coroutines.JobImpl#<init>(kotlinx.coroutines.Job?){} + 150 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/JobSupport.kt:1328:46)
at 7 DriversAppApi 0x00000001017d692c kfun:kotlinx.coroutines#Job(kotlinx.coroutines.Job?){}kotlinx.coroutines.CompletableJob + 188 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/Job.kt:379:55)
at 8 DriversAppApi 0x00000001019f9254 kfun:io.ktor.client.HttpClient#<init>(io.ktor.client.engine.HttpClientEngine;io.ktor.client.HttpClientConfig<out|io.ktor.client.engine.HttpClientEngineConfig>){} + 1796 (/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-client/ktor-client-core/common/src/io/ktor/client/HttpClient.kt:87:45)
at 9 DriversAppApi 0x00000001019fa310 kfun:io.ktor.client.HttpClient#<init>(io.ktor.client.engine.HttpClientEngine;io.ktor.client.HttpClientConfig<out|io.ktor.client.engine.HttpClientEngineConfig>;kotlin.Boolean){} + 144 (/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-client/ktor-client-core/common/src/io/ktor/client/HttpClient.kt:81:9)
at 10 DriversAppApi 0x00000001019f8ad5 kfun:io.ktor.client#HttpClient(io.ktor.client.engine.HttpClientEngine;kotlin.Function1<io.ktor.client.HttpClientConfig<*>,kotlin.Unit>){}io.ktor.client.HttpClient + 517 (/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-client/ktor-client-core/common/src/io/ktor/client/HttpClient.kt:62:17)
at 11 DriversAppApi 0x00000001011b389d kfun:com.arrival.adp.drivers.app.api.rest.HttpClientFactory#create(){}io.ktor.client.HttpClient + 285 (/Users/alexander.ivanov/Development/pmob-sdrv-graphql-api-tool/sources/drivers-app-api/src/commonMain/kotlin/com/arrival/adp/drivers/app/api/rest/HttpClientFactory.kt:31:16)
My version changes:
kotlin: 1.4.32
-> 1.5.10
Ktor: 1.5.3
-> 1.6.0
kotlinx.coroutines: 1.4.3-native-mt
-> 1.5.0-native-mt
kotlinx.serialization: 1.1.0
-> 1.2.1
Does somebody faced this issue?Ankit Dubey
06/24/2021, 7:02 AMval query = hashMapOf<String,Any>(
KEY_OTP to otp.toInt(),
KEY_MOBILE to phone
)
This is what I’ve posted
However I achieved the excepted result by sending a model class as
@Serializable
data class OTPRequest(
val mobile : String,
val otp : Int
)
But I was wondering, It’ll be a extra burden if I’m going to create multiple request classes
Any solution will be helpful.
thanksjean
06/24/2021, 7:50 AMSean Abbott
06/24/2021, 2:10 PMfun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)
fun Application.module(testing: Boolean = false) {
install(ContentNegotiation) {
json()
}
install(CallLogging)
registerAccountRoutes()
registerHealthRoutes()
}
The install ContentNegotiation works, but CallLogging isn't doing anything as far as I can tell.Sean Abbott
06/24/2021, 6:28 PMroute("/foo") {
get("{bar}") {
if not validFoo(call.parameters) return@get call.respondText("invalid", status = HttpStatusCode.BadRequest)
launch { longRunningWorkIDontNeedAResponseFrom(call.parameters) }
call.respondText("Started work")
}
}
I know I'm using coroutine already, but...do I need to set up the coroutine scope? Can I share a thread pool with ktor?jean
06/25/2021, 8:30 AMdocker build -t my-app .
I’m getting this error message :
=> ERROR [3/4] COPY ./build/install/docker/ /app/
------
> [3/4] COPY ./build/install/docker/ /app/:
------
failed to compute cache key: "/build/install/docker" not found: not found
What am I doing wrong here?Himanshu Singh
06/26/2021, 11:26 AMException in thread "main" io.ktor.application.DuplicateApplicationFeatureException: Conflicting application feature is already installed with the same key as `CORS`
And the code looks like:
fun main() {
embeddedServer(Netty, port = 8081, host = "0.0.0.0") {
configureHTTP()
configureOauth()
configureRoutingAndSerialization()
configureStatusPages()
}.start(wait = true)
}
The weird part is:
The first feature which is inside the blocks always throws the error. In this case is HTTP but if I take Oauth to first position it will throw exception of Authentication
Nikolay Kasyanov
06/26/2021, 12:26 PMmaskipli
06/27/2021, 4:46 AMsealed class NetworkResponse<out S : Any, out E : Any> {
data class Success<S : Any>(
val body: S,
val code: Int
) : NetworkResponse<S, Nothing>()
data class Error<E : Any>(
val errorBody: E,
val code: Int
) : NetworkResponse<Nothing, E>()
data class Failure(val error: Exception) : NetworkResponse<Nothing, Nothing>()
}
Stewart Matheson
06/28/2021, 10:55 PMStewart Matheson
06/28/2021, 10:55 PMBig Chungus
06/28/2021, 11:06 PMStewart Matheson
06/28/2021, 11:15 PMmsink
06/29/2021, 5:02 AMpacman
as package manager.
As for examples - https://github.com/msink/hello-curl builds static app for both 32 and 64 bit native Windows, locally and on GitHub CI.Stewart Matheson
06/29/2021, 5:45 AMe: C:\Users\StewartMatheson\Documents\NotInventedHere\ktor\ktor-io\posix\src\io\ktor\utils\io\errors\PosixErrors.kt: (11, 30): Cannot access class 'platform.posix.SOCKET'. Check your module classpath for missing or conflicting dependencies
e: C:\Users\StewartMatheson\Documents\NotInventedHere\ktor\ktor-io\posix\src\io\ktor\utils\io\streams\PosixIo.kt: (78, 27): Cannot access class 'platform.posix.SOCKET'. Check your module classpath for missing or conflicting dependencies
e: C:\Users\StewartMatheson\Documents\NotInventedHere\ktor\ktor-io\posix\src\io\ktor\utils\io\streams\PosixIo.kt: (78, 27): Type mismatch: inferred type is KX_SOCKET /* = SOCKET */ but Int was expected
e: C:\Users\StewartMatheson\Documents\NotInventedHere\ktor\ktor-io\posix\src\io\ktor\utils\io\streams\PosixIo.kt: (93, 17): Cannot access class 'platform.posix.SOCKET'. Check your module classpath for missing or conflicting dependencies
e: C:\Users\StewartMatheson\Documents\NotInventedHere\ktor\ktor-io\posix\src\io\ktor\utils\io\streams\PosixIo.kt: (93, 17): Type mismatch: inferred type is KX_SOCKET /* = SOCKET */ but Int was expected
e: C:\Users\StewartMatheson\Documents\NotInventedHere\ktor\ktor-io\posix\src\io\ktor\utils\io\streams\PosixIo.kt: (98, 12): Cannot access class 'platform.posix.SOCKET'. Check your module classpath for missing or conflicting dependencies
e: C:\Users\StewartMatheson\Documents\NotInventedHere\ktor\ktor-io\posix\src\io\ktor\utils\io\streams\PosixIo.kt: (98, 17): Cannot access class 'platform.posix.SOCKET'. Check your module classpath for missing or conflicting dependencies
e: C:\Users\StewartMatheson\Documents\NotInventedHere\ktor\ktor-io\posix\src\io\ktor\utils\io\streams\PosixIo.kt: (174, 27): Cannot access class 'platform.posix.SOCKET'. Check your module classpath for missing or conflicting dependencies
e: C:\Users\StewartMatheson\Documents\NotInventedHere\ktor\ktor-io\posix\src\io\ktor\utils\io\streams\PosixIo.kt: (174, 27): Type mismatch: inferred type is KX_SOCKET /* = SOCKET */ but Int was expected
e: C:\Users\StewartMatheson\Documents\NotInventedHere\ktor\ktor-io\posix\src\io\ktor\utils\io\streams\PosixIo.kt: (196, 31): Cannot access class 'platform.posix.SOCKET'. Check your module classpath for missing or conflicting dependencies
e: C:\Users\StewartMatheson\Documents\NotInventedHere\ktor\ktor-io\posix\src\io\ktor\utils\io\streams\PosixIo.kt: (196, 31): Type mismatch: inferred type is KX_SOCKET /* = SOCKET */ but Int was expected
e: C:\Users\StewartMatheson\Documents\NotInventedHere\ktor\ktor-io\posix\src\io\ktor\utils\io\streams\PosixIo.kt: (196, 94): Type mismatch: inferred type is CValuesRef<IntVarOf<KX_SOCKADDR_LEN /* = Int */>> but CValuesRef<socklen_tVar /* = UIntVarOf<UInt> */>? was expected
e: C:\Users\StewartMatheson\Documents\NotInventedHere\ktor\ktor-io\posix\src\io\ktor\utils\io\streams\PosixIo.kt: (218, 29): Cannot access class 'platform.posix.SOCKET'. Check your module classpath for missing or conflicting dependencies
e: C:\Users\StewartMatheson\Documents\NotInventedHere\ktor\ktor-io\posix\src\io\ktor\utils\io\streams\PosixIo.kt: (218, 29): Type mismatch: inferred type is KX_SOCKET /* = SOCKET */ but Int was expected
e: C:\Users\StewartMatheson\Documents\NotInventedHere\ktor\ktor-io\posix\src\io\ktor\utils\io\streams\PosixIo.kt: (218, 91): Type mismatch: inferred type is KX_SOCKADDR_LEN /* = Int */ but socklen_t /* = UInt */ was expected
> Task :cinteropLibcurlMingw32 FAILED
Exception in thread "main" java.lang.Error: C:\Users\STEWAR~1\AppData\Local\Temp\1473305343316438614.c:1:10: fatal error: 'curl/curl.h' file not found
at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:152)
at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.indexDeclarations(Indexer.kt:1003)
at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.buildNativeIndexImpl(Indexer.kt:992)
at org.jetbrains.kotlin.native.interop.indexer.NativeIndexKt.buildNativeIndex(NativeIndex.kt:91)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:268)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:76)
at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:45)
at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:38)
at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:60)
msink
06/29/2021, 5:59 AMpacman -S mingw-w64-x86_64-curl mingw-w64-i686-curl
in MSYS2 shell.Stewart Matheson
06/29/2021, 10:41 PM.def
file in kotlin native. Perhaps the cinterops are not even running. This might happen if nativeTargets
in build.gradle.kts
in the ktor-io project is not set. I will start debugging that today. Any other suggests are more than welcome.
nativeTargets.forEach {
it.compilations {
val main by getting {
cinterops {
val bits by creating { defFile = file("posix/interop/bits.def") }
val sockets by creating { defFile = file("posix/interop/sockets.def") }
}
}
val test by getting {
cinterops {
val testSockets by creating { defFile = file("posix/interop/testSockets.def") }
}
}
}
}
msink
06/30/2021, 12:20 PMmain
and 1.6.0
- build failed with exactly same errors, on tag 1.5.4
- build passed.1.6.0
for windows was published...:ktor-io:compilePosixMainKotlinMetadata
failed on 1.5.4
too, but after 30 minutes of various tests.