https://kotlinlang.org logo
#ktor
Title
# ktor
r

reactormonk

03/15/2024, 12:13 PM
Copy code
export RABBITMQ_URL=guest:guest@localhost:15672
Copy code
val rabbitmqURL = System.getenv("RABBITMQ_URL")
    val url = URLBuilder()
    url.takeFrom(rabbitmqURL)
Gives me
Copy code
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?
a

Aleksei Tirman [JB]

03/15/2024, 1:41 PM
Can you tell me what URL scheme is that?
r

reactormonk

03/15/2024, 1:41 PM
http url with user/password
a

Aleksei Tirman [JB]

03/15/2024, 1:43 PM
According to the specification, the URL should start with
//
then.
r

reactormonk

03/15/2024, 1:43 PM
Changed that, doesn't seem to parse
user
correctly 😞
a

Aleksei Tirman [JB]

03/15/2024, 1:45 PM
Can you please check the following code?
Copy code
val url = Url("//user:pass@localhost:15672/abc")
println(url.host)
println(url.port)
println(url.user)
println(url.password)
println(url.encodedPath)
r

reactormonk

03/15/2024, 1:45 PM
The
URI
parser seems to work as it should, I'll go with that
2024-03-15 144546.959 [eventLoopGroupProxy-4-1] TRACE i.k.c.plugins.defaultTransformers - Transformed with default transformers response body for http://guest:guest@localhost:15672/api/vhosts/d8e989a9-0fae-4b3e-ad78-15bd67a80c55 to class io.ktor.utils.io.core.ByteReadPacket Looks good
Still looks good, but something's weird, it's not being accepted by the other side.
j

Júlio Santos

03/19/2024, 8:11 PM
Hey @reactormonk! Are you using application.conf or yaml? I always leave information such as database variables and URLs in this file