Robin T
03/12/2024, 8:33 AMwhen (val fileItem = call.receiveMultipart().readAllParts().single()) {
is PartData.FileItem -> {
fileItem.provider().use {
it.readByte()
}
}
else -> error("")
}
But it.readByte()
is returning -1.
Also, it.canRead()
is returning false.
However, if I first call it.tryPeek()
then I am able to call readBytes. and it.canRead()
is returning true again.
Does this have something to do with the chunkbuffer-pool not being setup for read yet?Stephan Schröder
03/12/2024, 9:31 AMgetOrPut
, so
data object ProxyMode {
private val certificateCache: MutableMap<String, BCECPublicKey> = mutableMapOf()
private val lock = Mutex()
...
suspend fun getRequest(...): Pair<HttpClient, RequestData> {
...
val serverEncPublicKey: BCECPublicKey = lock.withLock { certificateCache.getOrPut(host) {
loadCertificate("https://$host/Certificate").bcecPublicKey
} }
...
}
}
but I wonder if a way exists where the locking is part of the collection class but which still locks the coroutine and not the thread.Javier
03/12/2024, 12:57 PMHarpreet Singh.8052
03/12/2024, 1:47 PMApi
keys inside my ktor
app (mongoDb connection String and OneSiganl key for Notificaton) , i added that keys inside my application.config
file and that file to .gitignore
and containarize the app using Docker
its my first time using docker and when i deployed , it showing error that not able to access those keys that are inside applicaton.config
, so my question is where can i add those keys so that , it wont stuck on versionContol or usabel inside my dockerbrabo-hi
03/12/2024, 6:32 PMAntonio Acuña Prieto
03/12/2024, 8:43 PMTestApplication {
environment {
config = ApplicationConfig("application.conf")
}
}
Modules defined in application.conf
load fine, but when I try to override any parameter of the configuration using:
TestApplication {
environment {
config = ApplicationConfig("application.conf").mergeWith(
MapApplicationConfig(
"database.host" to "whatever",
)
)
}
}
Then the modules are loaded two times. Version 3.0.0-beta-1Ahmed Riyadh
03/12/2024, 9:28 PMrebok
03/12/2024, 9:55 PMAhmed Riyadh
03/13/2024, 2:58 AMAhmed Riyadh
03/13/2024, 3:41 AMFernando Sanchez (Perraco Labs)
03/13/2024, 9:36 AMapplication {
mainClass.set("$group.ApplicationKt")
}
But for the child sub-projects, I had to set the main class to empty:
application {
mainClass.set("")
}
If I don't do this, I encounter an exception when running the buildFatJar task:
Execution failed for task ':kcrud-employment:shadowJar'.
Error while evaluating property 'mainClassName' of task ':kcrud-employment:shadowJar'.
Cannot query the value of extension 'application' property 'mainClass' because it has no value available.
Is it expected behavior to explicitly set the mainClass to empty for sub-projects? I assumed this would be implicitly detected by the Gradle task.Nikky
03/13/2024, 11:21 AMexecute
block with this code
val channel: ByteReadChannel = response.body()
flow {
logger.warn { "closed for read: " + channel.isClosedForRead }
while (!channel.isClosedForRead) {
val line = channel.readUTF8Line()
if(line != null) {
emit(line)
}
}
}
but it seems that channel.isClosedForRead
is always true
maybe because there is no content-length header ? i don't really know
curl is able to stream the data just fineegor
03/13/2024, 11:59 AMjava.net.SocketException: Software caused connection abort
at <http://java.net|java.net>.SocketInputStream.socketRead0(SocketInputStream.java)
at <http://java.net|java.net>.SocketInputStream.socketRead(SocketInputStream.java:118)
at <http://java.net|java.net>.SocketInputStream.read(SocketInputStream.java:173)
at <http://java.net|java.net>.SocketInputStream.read(SocketInputStream.java:143)
at <http://com.android.org|com.android.org>.conscrypt.ConscryptEngineSocket$SSLInputStream.readFromSoc
egor
03/13/2024, 11:59 AMFatal Exception: <http://javax.net|javax.net>.ssl.SSLException: Read error: ssl=0xb400006d72f90c18: I/O error during system call, Software caused connection abort
at <http://com.google.android.gms.org|com.google.android.gms.org>.conscrypt.NativeCrypto.SSL_read(:com.google.android.gms@240812038@24.08.12 (190400-608507424))
at <http://com.google.android.gms.org|com.google.android.gms.org>.conscrypt.NativeSsl.read(:com.google.android.gms@240812038@24.08.12 (190400-608507424):34)
at <http://com.google.android.gms.org|com.google.android.gms.org>.conscrypt.ConscryptFileDescriptorSocket$SSLInputStream.read(:com.google.android.gms@240812038@24.08.12 (190400-608507424):11)
at okio.InputStreamSource.read(JvmOkio.kt:93)
at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:128)
Kaj Koivunen
03/14/2024, 2:52 PMError: Could not find or load main class ktortest-all.jar
darkmoon_uk
03/14/2024, 10:46 PMRobert Jaros
03/15/2024, 12:02 PMsingePageApplication()
, but with a server generated index.html
. I've created this configuration:
routing {
get("/index.html") {
call.respondText(
"<html><head><title>Custom index.html</title></head><body></body></html>",
ContentType.Text.Html
)
}
singlePageApplication {
defaultPage = "index.html"
filesPath = "/assets"
useResources = true
}
}
but unfortunately it doesn't work (not existing urls are redirected to /assets/index.html
file instead of my /index.html
endpoint). Can I somehow do this with a simple configuration or do I have to implement the whole thing from scratch?reactormonk
03/15/2024, 12:13 PMexport RABBITMQ_URL=guest:guest@localhost:15672
val rabbitmqURL = System.getenv("RABBITMQ_URL")
val url = URLBuilder()
url.takeFrom(rabbitmqURL)
Gives me
2024-03-15 13:11:55.989 [eventLoopGroupProxy-4-2] TRACE i.k.client.plugins.HttpCallValidator - Processing exception java.net.ConnectException: Connection refused for request <guest://localhost/guest@localhost:15672/api/vhosts/eb1de2cd-f9bc-4d50-876f-28bb891da301>
So I have a feeling that takeFrom
can't parse URLs fully?reactormonk
03/15/2024, 2:30 PM2024-03-15 15:26:48.224 [eventLoopGroupProxy-4-1] TRACE i.k.server.engine.DefaultTransform - No Default Transformations found for class io.ktor.utils.io.ByteBufferChannel and expected type TypeInfo(type=class net.familycards.plugins.HashedPasswords, reifiedType=class net.familycards.plugins.HashedPasswords, kotlinType=net.familycards.plugins.HashedPasswords) for call /users
2024-03-15 15:26:48.356 [eventLoopGroupProxy-4-1] TRACE i.k.c.p.c.ContentNegotiation - Adding Accept=application header for <http://guest:guest@localhost:15672/api/vhosts/bfd7e17b-a95b-476a-b022-cafcc9f57d99>
2024-03-15 15:26:48.393 [eventLoopGroupProxy-4-1] TRACE i.k.c.p.c.ContentNegotiation - Converted request body using io.ktor.serialization.kotlinx.KotlinxSerializationConverter@7f6cc440 for <http://guest:guest@localhost:15672/api/vhosts/bfd7e17b-a95b-476a-b022-cafcc9f57d99>
2024-03-15 15:26:48.393 [eventLoopGroupProxy-4-1] TRACE i.ktor.client.plugins.HttpPlainText - Adding Accept-Charset=UTF-8 to <http://guest:guest@localhost:15672/api/vhosts/bfd7e17b-a95b-476a-b022-cafcc9f57d99>
2024-03-15 15:26:48.394 [eventLoopGroupProxy-4-1] TRACE i.k.c.plugins.defaultTransformers - Transformed with default transformers request body for <http://guest:guest@localhost:15672/api/vhosts/bfd7e17b-a95b-476a-b022-cafcc9f57d99> from class io.ktor.http.content.TextContent
2024-03-15 15:26:48.472 [eventLoopGroupProxy-4-1] TRACE i.k.client.plugins.HttpCallValidator - Validating response for request <http://guest:guest@localhost:15672/api/vhosts/bfd7e17b-a95b-476a-b022-cafcc9f57d99>
2024-03-15 15:26:48.473 [eventLoopGroupProxy-4-1] TRACE i.k.c.p.DefaultResponseValidation - Skipping default response validation for <http://guest:guest@localhost:15672/api/vhosts/bfd7e17b-a95b-476a-b022-cafcc9f57d99>
2024-03-15 15:26:48.484 [eventLoopGroupProxy-4-1] TRACE i.k.c.p.c.ContentNegotiation - Response doesn't have "Content-Type" header, skipping ContentNegotiation plugin
2024-03-15 15:26:48.484 [eventLoopGroupProxy-4-1] TRACE i.k.c.plugins.defaultTransformers - Transformed with default transformers response body for <http://guest:guest@localhost:15672/api/vhosts/bfd7e17b-a95b-476a-b022-cafcc9f57d99> to class io.ktor.utils.io.core.ByteReadPacket
2
And httpie:
http PUT <http://guest:guest@localhost:15672/api/vhosts/bfd7e17b-a95b-476a-b022-cafcc9f57d9a> default_queue_type=classic
HTTP/1.1 201 Created
content-length: 0
content-security-policy: script-src 'self' 'unsafe-eval' 'unsafe-inline'; object-src 'self'
date: Fri, 15 Mar 2024 14:27:34 GMT
server: Cowboy
vary: accept, accept-encoding, origin
Mohammad Jaber
03/15/2024, 5:19 PMDeepak Gahlot
03/17/2024, 9:26 AMimport com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.com.intellij.openapi.vfs.StandardFileSystems.jar
val ktor_version: String by project
val kotlin_version: String by project
val logback_version: String by project
val exposed_version: String by project
val postgres_version: String by project
val hikari_version: String by project
plugins {
kotlin("jvm") version "1.9.22"
id("io.ktor.plugin") version "2.3.8"
kotlin("plugin.serialization") version "1.9.22"
id("com.github.johnrengelman.shadow") version "7.1.2"
}
group = "com.schoolcircle"
version = "0.0.1"
application {
mainClass.set("com.schoolcircle.ApplicationKt")
}
tasks {
withType<Jar> {
manifest {
attributes["Main-Class"] = "com.schoolcircle.ApplicationKt"
}
}
}
//tasks.shadowJar {
// manifest {
// attributes["Main-Class"] = application.mainClass.get()
// }
//}
repositories {
mavenCentral()
maven {
url = uri("<https://dl.bintray.com/kotlin/exposed>")
}
maven { url = uri("<https://kotlin.bintray.com/ktor>") }
maven {
url = uri("<https://repo.spring.io/release>")
}
google()
}
tasks {
create("stage").dependsOn("installDist")
}
tasks.test {
enabled = false
}
gradle.taskGraph.whenReady {
if (this.hasTask("stage")) {
tasks.test {
enabled = false
}
}
}
dependencies {
implementation("io.ktor:ktor-server-auth-jvm")
implementation("io.ktor:ktor-server-core-jvm")
implementation("io.ktor:ktor-server-auth-jwt-jvm")
implementation("io.ktor:ktor-server-sessions-jvm")
implementation("io.ktor:ktor-server-netty-jvm")
implementation("io.ktor:ktor-server-locations:$kotlin_version")
implementation("ch.qos.logback:logback-classic:$logback_version")
implementation("io.ktor:ktor-server-content-negotiation:$ktor_version")
implementation("io.ktor:ktor-serialization-jackson:$ktor_version")
testImplementation("io.ktor:ktor-server-tests-jvm")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
testImplementation ("io.ktor:ktor-server-tests:$ktor_version")
implementation("org.jetbrains.exposed:exposed-core:$exposed_version")
implementation("org.jetbrains.exposed:exposed-dao:$exposed_version")
implementation("org.jetbrains.exposed:exposed-jdbc:$exposed_version")
implementation("org.postgresql:postgresql:$postgres_version")
implementation("com.zaxxer:HikariCP:$hikari_version")
}
this is my application class
package com.schoolcircle
import com.schoolcircle.authentication.JwtService
import com.schoolcircle.authentication.hash
import com.schoolcircle.data.services.adminUtils.AdminServicesImpl
import com.schoolcircle.data.services.student.StudentServiceImpl
import com.schoolcircle.data.services.tenant.TenantServiceImpl
import com.schoolcircle.data.services.user.UserServiceImpl
import com.schoolcircle.data.services.userManagement.UserManagementServiceImpl
import com.schoolcircle.plugins.*
import com.schoolcircle.repository.DatabaseFactory
import io.ktor.serialization.jackson.*
import io.ktor.server.application.*
import io.ktor.server.engine.*
import io.ktor.server.locations.*
import io.ktor.server.netty.*
import io.ktor.server.plugins.contentnegotiation.*
fun main(args: Array<String>): Unit = EngineMain.main(args)
@OptIn(KtorExperimentalLocationsAPI::class)
fun Application.module() {
DatabaseFactory.init()
install(Locations)
install(ContentNegotiation) {
jackson()
}
val userDb = UserServiceImpl()
val tenantDb = TenantServiceImpl()
val adminDb = AdminServicesImpl()
val userManagementDb = UserManagementServiceImpl()
val studentDb = StudentServiceImpl()
val jwtService = JwtService()
val hashFunction = {s: String -> hash(s) }
configureSecurity()
configureRouting(
tenantDb = tenantDb,
userDb = userDb,
jwtService = jwtService,
adminDb = adminDb,
studentDb = studentDb,
userManagementDb = userManagementDb,
hashFunction = hashFunction
)
}
Procfile
web: java -jar ./build/libs/school-backend-0.0.1.jar
Deepak Gahlot
03/17/2024, 9:27 AMError: A JNI error has occurred, please check your installation and try again
2024-03-17T09:17:09.316598+00:00 app[web.1]: Exception in thread "main" java.lang.NoClassDefFoundError: io/ktor/server/application/Application
If any other information is require please let me knowRoger Kreienbühl
03/18/2024, 9:50 AM2024-03-18 10:48:01.123799+0100 MapComposeKMP[61711:129348692] [connection] nw_connection_copy_connected_local_endpoint_block_invoke [C3] Connection has no local endpoint
2024-03-18 10:48:01.123974+0100 MapComposeKMP[61711:129348692] [connection] nw_connection_copy_connected_local_endpoint_block_invoke [C3] Connection has no local endpoint
2024-03-18 10:48:01.142466+0100 MapComposeKMP[61711:129348692] [connection] nw_connection_copy_connected_local_endpoint_block_invoke [C1] Connection has no local endpoint
2024-03-18 10:48:01.142588+0100 MapComposeKMP[61711:129348692] [connection] nw_connection_copy_connected_local_endpoint_block_invoke [C1] Connection has no local endpoint
2024-03-18 10:48:01.148331+0100 MapComposeKMP[61711:129348692] [connection] nw_connection_copy_connected_local_endpoint_block_invoke [C2] Connection has no local endpoint
2024-03-18 10:48:01.148481+0100 MapComposeKMP[61711:129348692] [connection] nw_connection_copy_connected_local_endpoint_block_invoke [C2] Connection has no local endpoint
2024-03-18 10:48:01.166921+0100 MapComposeKMP[61711:129348692] [connection] nw_connection_copy_connected_local_endpoint_block_invoke [C33] Client called nw_connection_copy_connected_local_endpoint on unconnected nw_connection
2024-03-18 10:48:01.166997+0100 MapComposeKMP[61711:129348692] [connection] nw_connection_copy_connected_remote_endpoint_block_invoke [C33] Client called nw_connection_copy_connected_remote_endpoint on unconnected nw_connection
2024-03-18 10:48:01.167066+0100 MapComposeKMP[61711:129348692] [connection] nw_connection_copy_protocol_metadata_internal_block_invoke [C33] Client called nw_connection_copy_protocol_metadata_internal on unconnected nw_connection
2024-03-18 10:48:01.170345+0100 MapComposeKMP[61711:129348692] [connection] nw_connection_copy_connected_local_endpoint_block_invoke [C4] Connection has no local endpoint
2024-03-18 10:48:01.170513+0100 MapComposeKMP[61711:129348692] [connection] nw_connection_copy_connected_local_endpoint_block_invoke [C4] Connection has no local endpoint
2024-03-18 10:48:01.172609+0100 MapComposeKMP[61711:129348692] [connection] nw_connection_copy_connected_local_endpoint_block_invoke [C34] Client called nw_connection_copy_connected_local_endpoint on unconnected nw_connection
2024-03-18 10:48:01.172683+0100 MapComposeKMP[61711:129348692] [connection] nw_connection_copy_connected_remote_endpoint_block_invoke [C34] Client called nw_connection_copy_connected_remote_endpoint on unconnected nw_connection
2024-03-18 10:48:01.172745+0100 MapComposeKMP[61711:129348692] [connection] nw_connection_copy_protocol_metadata_internal_block_invoke [C34] Client called nw_connection_copy_protocol_metadata_internal on unconnected nw_connection
2024-03-18 10:48:01.177893+0100 MapComposeKMP[61711:129348692] [connection] nw_connection_copy_connected_local_endpoint_block_invoke [C35] Client called nw_connection_copy_connected_local_endpoint on unconnected nw_connection
2024-03-18 10:48:01.180078+0100 MapComposeKMP[61711:129348692] [connection] nw_connection_copy_connected_remote_endpoint_block_invoke [C35] Client called nw_connection_copy_connected_remote_endpoint on unconnected nw_connection
2024-03-18 10:48:01.180129+0100 MapComposeKMP[61711:129348692] [connection] nw_connection_copy_protocol_metadata_internal_block_invoke [C35] Client called nw_connection_copy_protocol_metadata_internal on unconnected nw_connection
2024-03-18 10:48:01.185247+0100 MapComposeKMP[61711:129348692] [connection] nw_connection_copy_connected_local_endpoint_block_invoke [C5] Connection has no local endpoint
2024-03-18 10:48:01.185424+0100 MapComposeKMP[61711:129348692] [connection] nw_connection_copy_connected_local_endpoint_block_invoke [C5] Connection has no local endpoint
2024-03-18 10:48:01.190536+0100 MapComposeKMP[61711:129348692] [connection] nw_connection_copy_connected_local_endpoint_block_invoke [C6] Connection has no local endpoint
2024-03-18 10:48:01.190797+0100 MapComposeKMP[61711:129348692] [connection] nw_connection_copy_connected_local_endpoint_block_invoke [C6] Connection has no local endpoint
My code looks like this:
try {
HttpClient(Darwin) {
engine {
configureRequest {
setAllowsCellularAccess(true)
}
}
}.use {
val response: HttpResponse = it.get("<https://tile.openstreetmap.org/$zoomLvl/$col/$row.png>")
response.readBytes().asSequence()
}
} catch (e: Exception) {
e.printStackTrace()
null
}
What am I doing wrong?darkmoon_uk
03/18/2024, 10:58 AM3.0.0
due to support WASM?
Currently there are versions 3.0.0-wasm2
and 3.0.0-beta-1
, where the Beta doesn't have WASM artifacts 🤔rebok
03/18/2024, 11:35 AMFernando Sanchez (Perraco Labs)
03/18/2024, 3:57 PM亀窪翼
03/18/2024, 6:05 PMktor {
deployment {
port = 8080
}
application {
modules = [ com.plugins.RoutingKt.configureRouting ]
}
}
java -jar /app/build/libs/app-0.0.1.jar -config=/app/src/main/resources/application.conf
SLF4J: No SLF4J providers were found.
2024-03-18T18:04:05.095166467Z SLF4J: Defaulting to no-operation (NOP) logger implementation
2024-03-18T18:04:05.095175467Z SLF4J: See <https://www.slf4j.org/codes.html#noProviders> for further details.
2024-03-18T18:04:05.109629884Z Exception in thread "main" java.lang.IllegalArgumentException: Neither port nor sslPort specified. Use command line options -port/-sslPort or configure connectors in application.conf
2024-03-18T18:04:05.109770926Z at io.ktor.server.engine.CommandLineKt$buildCommandLineEnvironment$environment$1.invoke(CommandLine.kt:78)
2024-03-18T18:04:05.109785259Z at io.ktor.server.engine.CommandLineKt$buildCommandLineEnvironment$environment$1.invoke(CommandLine.kt:39)
2024-03-18T18:04:05.109797217Z at io.ktor.server.engine.ApplicationEngineEnvironmentBuilder.build(ApplicationEngineEnvironmentJvm.kt:74)
2024-03-18T18:04:05.110948301Z at io.ktor.server.engine.ApplicationEngineEnvironmentKt.applicationEngineEnvironment(ApplicationEngineEnvironment.kt:48)
2024-03-18T18:04:05.110997926Z at io.ktor.server.engine.CommandLineKt.buildCommandLineEnvironment(CommandLine.kt:39)
2024-03-18T18:04:05.111004134Z at io.ktor.server.engine.CommandLineKt.commandLineEnvironment(CommandLine.kt:98)
2024-03-18T18:04:05.111008509Z at io.ktor.server.netty.EngineMain.main(EngineMain.kt:20)
2024-03-18T18:04:05.111012426Z at com.ApplicationKt.main(Application.kt:6)
Please tell me why this is happening.rnett
03/18/2024, 6:34 PMmarzelwidmer
03/18/2024, 9:21 PMjw
03/19/2024, 12:01 AM