Ayodele
06/30/2020, 10:19 AMStefan Peterson
06/30/2020, 11:39 PMINFO
level. For a Logback provider I have logback-classic
declared as a dependency in my pom.xml
and set up a logback.xml
file src > main > resources but when I try to access the default logger in any ApplicationCall context I am still seeing DEBUG
level logs.
My logback.xml
looks like the following:
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="info">
<appender-ref ref="STDOUT"/>
</root>
<logger name="org.eclipse.jetty" level="INFO"/>
<logger name="io.netty" level="INFO"/>
<logger name="ktor.application" level="INFO" />
</configuration>
Gunslingor
07/01/2020, 5:16 AMdarkmoon_uk
07/01/2020, 1:19 PMktor-auth-kotlinMultiplatform
package in version 1.3.1
so I took it's disappearance from 1.3.2
to mean the MPP metadata became included as standard for ktor-auth
itself... no?Shawn Karber_
07/01/2020, 4:34 PMval client = HttpClient(HttpClientEngine) {
install(JsonFeature) {
serializer = GsonSerializer()
}
}
but theres an issue with HttpClient(HttpClientEngine)
The error says HttpClientEngine
does not have a companion object, thus must be initialized here, what am I doing wrong?Nikolaj
07/02/2020, 8:05 AMOsmium
07/02/2020, 10:47 AMThreadLocal.asContextElement
and stuff (i'm bad at coroutines, to be honest), and i'm curious if someone already implemented that...LastExceed
07/02/2020, 11:41 AMjava.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class Post
. It seems T is getting erased despite being reified. why is that ?manlan
07/03/2020, 6:32 AMagta1991
07/03/2020, 8:50 AMGunslingor
07/03/2020, 10:35 PMregister<Exec>("runFatJarLocallyInDocker") {
group = "application"
dependsOn(mutableSetOf<Any>("buildFatJar"))
commandLine = mutableListOf("cmd", "dir")
val std = standardOutput
doLast {
println()
println("Output: ${std.toString()}")
println("Error: ${errorOutput.toString()}")
}
/*
commandLine(
"docker dir",
"docker build -t ${project.name}-fat.jar",
"docker run -m512M --cpus 2 -it -p 8080:8080 --rm ${project.name}-fat.jar"
)*/
}
Kepha
07/06/2020, 1:34 AMKepha
07/06/2020, 1:45 AM/**
* Initiate connection termination immediately. Termination may complete asynchronously.
*/
@Deprecated(
"Use cancel() instead.",
ReplaceWith("cancel()", "kotlinx.coroutines.cancel")
)
actual fun terminate()
What is the difference between terminate() and cancel() ?Rodrigo Silva
07/06/2020, 11:37 AMShawn A
07/06/2020, 4:00 PMRachid
07/06/2020, 7:54 PMError:(3, 23) Kotlin: Unresolved reference: HttpClient
When I CMD+click on that import it jumps to the "ktor-client-core" external lib.
Yesterday I somehow fiddled enough to get rid of this error, but today it popped up again. Now I can't start the JVM process anymore. In Gradle for both JVM as common I have these deps:
implementation "io.ktor:ktor-client-core:$ktor_version"
implementation "io.ktor:ktor-client-websockets:$ktor_version"
Any idea what's wrong here?Gunslingor
07/07/2020, 2:54 AMregister<Jar>("buildFatJar") {
group = "application"
manifest {
attributes["Implementation-Title"] = "Gradle Jar File Example"
attributes["Implementation-Version"] = archiveVersion
attributes["Main-Class"] = "com.app.BackendAppKt"
}
archiveBaseName.set("${project.name}-fat")
from(main.output.classesDirs, main.compileDependencyFiles)
with(jar.get() as CopySpec)
}
register<JavaExec>("runLocally") {
group = "application"
setMain("com.app.BackendAppKt")
classpath = main.output.classesDirs
classpath += main.compileDependencyFiles
}
bbaldino
07/07/2020, 10:06 PMHttpClient
and I want to add a hook so I can pass a MockEngine
in for unit testing, but running into a few issues:
My first thought was to have the entire client be a ctor param and default it to what I want, i.e.:
class MyClass(
private val client: HttpClient = HttpClient(Apache) {
install(JsonFeature) { ... }
}
) {
but then if I pass in a mock client, MyClass
won't install the JsonFeature, so next I thought about passing in the engine:
class MyClass(
private val clientEngine: HttpClientEngine = Apache
) {
but this doesn't work because Apache
isn't an HttpClientEngine
, it's an HttpClientEngineFactory
. And I don't want to change the ctor to take in a HttpClientEngineFactory
because it has a generic type and I don't want to add a generic to the class just to support this. I'm assuming there must be something simple here I'm missing?Luis Munoz
07/08/2020, 2:18 AMcodec
07/08/2020, 3:04 AMLuis Munoz
07/08/2020, 4:02 AMval staticDir = "rest-api/static"
static("/") {
staticRootFolder = File(staticDir)
files("js")
default("index.html")
}
Dominic Michel
07/08/2020, 6:43 AMHttpClient {
expectSuccess = false
}
but if set, the exception just changes from ClientRequestException
to IllegalStateException
Can the throwing of exceptions somehow be prevented completely or do i have to resort to a try/catch block?Sean Najera
07/08/2020, 6:29 PM// MPP - JS & common dependencies
sourceSets["commonMain"].dependencies {
implementation(kotlin("stdlib-common", Versions.KOTLIN))
implementation(Deps.Ktor.COMMON_CORE)
implementation(Deps.Ktor.COMMON_JSON)
implementation(Deps.Coroutines.COMMON)
implementation(Deps.MP_SETTINGS)
implementation(Deps.Ktor.COMMON_SERIALIZER)
implementation(Deps.Serialization.COMMON)
implementation(Deps.Stately.COMMON)
implementation(Deps.Stately.CONCURRENCY)
}
sourceSets["jsMain"].dependencies {
implementation((kotlin("stdlib-js", Versions.KOTLIN)))
implementation(Deps.Ktor.JS_CORE)
implementation(Deps.Ktor.JS_JSON)
implementation(Deps.Coroutines.JS)
implementation(Deps.Ktor.JS_SERIALIZER)
implementation(Deps.Serialization.JS)
}
// Front-End react app dependencies
implementation(kotlin("stdlib-js"))
//React, React DOM + Wrappers (chapter 3)
implementation("org.jetbrains:kotlin-react:16.13.0-pre.94-kotlin-1.3.70")
implementation("org.jetbrains:kotlin-react-dom:16.13.0-pre.94-kotlin-1.3.70")
implementation(npm("react", "16.13.1"))
implementation(npm("react-dom", "16.13.1"))
//Kotlin Styled (chapter 3)
implementation("org.jetbrains:kotlin-styled:1.0.0-pre.94-kotlin-1.3.70")
implementation(npm("styled-components"))
implementation(npm("inline-style-prefixer"))
//Video Player (chapter 7)
implementation(npm("react-player"))
//Share Buttons (chapter 7)
implementation(npm("react-share"))
// Shared Library: Nautilus
implementation(project(":MarianaKit"))
//Coroutines (chapter 8)
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.7")
When I import the javascript library into the Jetbrains starter React app, the dev distribution size 27MiB and the production distribution size is 1.5 MiB. Is anyone else having such large distribution sizes? Is this normal? Or am I doing something on my end to cause this?janvladimirmostert
07/08/2020, 7:17 PMembeddedServer(
CIO,
module = Application::module,
port = if (ENV.env == LOCAL) {
7777
} else {
80
},
watchPaths = if (ENV.env == LOCAL) {
listOf("build")
} else {
listOf()
}
).apply {
start(wait = true)
}
bbaldino
07/09/2020, 5:46 PMclass MyClass {
val module: Application.() -> Unit {
...
}
}
and then it's installed/started via something like:
val myClass = MyClass()
embeddedServer(Jetty) {
myClass.module(this)
}
which isn't bad, but wondering if there's a better/more idiomatic way?Matt Kranzler
07/10/2020, 2:24 PMPOST -> <http://10.0.2.2:8080/account/login>
GET -> <http://10.0.2.2:8080/user/me>
POST -> <http://10.0.2.2:8080/user/devices>
The first two requests succeed but the third request is returning a 500 from my server with the following error:
org.springframework.security.web.firewall.RequestRejectedException: The request was rejected because the HTTP method "ST" was not included within the whitelist [HEAD, DELETE, POST, GET, OPTIONS, PATCH, PUT]
I've debugged the earliest entry point on the server side and verified the HTTP method is coming in as ST
. I've also enabled tomcat access logging and verified the request comes in with an HTTP method of ST
. On the Android/multiplatform side the ktor logging show the last request as a POST
and the Android Studio network profiler show the request as a POST
. What's even more weird is if I change the order of the requests to this:
POST -> <http://10.0.2.2:8080/account/login>
POST -> <http://10.0.2.2:8080/user/devices>
GET -> <http://10.0.2.2:8080/user/me>
it works fine and comes through as a POST
on the server side. What makes this even more difficult to track down is that I'm unable to debug on the client side because as soon as I run with the debugger or attach the debugger Android Studio and Intellij both lock up completely and I have to force quit. Does anyone have any ideas on what could be happening or any suggestions on what else to try?torres
07/10/2020, 2:47 PMException in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
..
at io.ktor.server.netty.NettyApplicationEngine.start(NettyApplicationEngine.kt:126)
at io.ktor.server.netty.EngineMain.main(EngineMain.kt:26)
at com.example.ApplicationKt.main(Application.kt:11)
Caused by: <http://java.net|java.net>.ConnectException: Connection refused
at <http://sun.nio.ch|sun.nio.ch>.SocketChannelImpl.checkConnect(Native Method)
at <http://sun.nio.ch|sun.nio.ch>.SocketChannelImpl.finishConnect(SocketChannelImpl.java:714)
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:174)
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:148)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:351)
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:221)
at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64)
at java.lang.Thread.run(Thread.java:821)
Gus
07/12/2020, 2:23 PMhandleWebSocketConversation
or anything related to WebSocket inside `addHandler`:
val ktorClient = HttpClient(MockEngine) {
engine {
addHandler { request ->
handleWebSocketConversation {}
}
}
}
pmiklos
07/12/2020, 8:12 PM[generateNonce] is not supported on iOS
coming from the WebSocketContent constructor. I found that there is no implementation for generateNonce
in the ktor-utils native library. It's kind of weird it says iOS when the targe platform is linux. Are websockets supposed to work on native linux platform?Jeff
07/13/2020, 1:54 PMI/System.out: [OkHttp] sendRequest>>
The code is as follows:
private val client by lazy {
HttpClient {
install(JsonFeature) {
serializer = KotlinxSerializer(
Json(
JsonConfiguration(
isLenient = true,
ignoreUnknownKeys = true
)
)
)
}
install(Logging) {
logger = Logger.DEFAULT
level = LogLevel.ALL
}
}
}
Jeff
07/13/2020, 1:54 PMI/System.out: [OkHttp] sendRequest>>
The code is as follows:
private val client by lazy {
HttpClient {
install(JsonFeature) {
serializer = KotlinxSerializer(
Json(
JsonConfiguration(
isLenient = true,
ignoreUnknownKeys = true
)
)
)
}
install(Logging) {
logger = Logger.DEFAULT
level = LogLevel.ALL
}
}
}
zalewski.se
07/14/2020, 2:35 AMlogger = Logger.SIMPLE
ritesh
07/14/2020, 7:23 AMlogger = MyLogger
...
object MyLogger: Logger {
override fun log(message: String) {
// log event like println or something else you want
}
}
Jeff
07/14/2020, 7:42 AM