Ktor with Android client throws IllegalStateException - responseMessage must not be null
See original GitHub issueKtor Version and Engine Used (client or server and name) Version 1.3.1 of Ktor client with Android module
Describe the bug
When I do a get request I am getting Exception in thread "main" java.lang.IllegalStateException: connection.responseMessage must not be null
To Reproduce
- Running with Java 11, with maven, kotlin stdlib and org.jetbrains.kotlin maven plugin.
import io.ktor.client.HttpClient
import io.ktor.client.engine.android.Android
import io.ktor.client.request.get
import io.ktor.client.statement.HttpResponse
import io.ktor.utils.io.readUTF8Line
import kotlinx.coroutines.runBlocking
fun main() {
runBlocking {
val response: HttpResponse = HttpClient(Android).get("http://api.chucknorris.io/jokes/random")
print(response.status.value)
print(response.content.readUTF8Line())
}
}
Expected behavior I would expect it should print the status code and response message, but it doesn’t reach at that point.
Screenshots
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Null connection in Ktor causing java.lang.IllegalStateException
I am trying to read data from an API-endpoint using Ktor and getting an IllegalStateException often regarding supposedly null connection.
Read more >Response validation - Ktor
If required, you can use the following validation strategies: Use the expectSuccess property to throw exceptions for non-2xx responses.
Read more >Ktor Http Client: Receive null on a not nullable field ... - YouTrack
Assume you want to query data from an API that responds with the following payload if everything works well, while the data field...
Read more >Using Ktor Client MockEngine for Integration and UI Tests
The project used in this article is a sample Android app which ... null get() = field ?: throw IllegalStateException("Mock has not beet ......
Read more >How to Build a Simple REST API With Ktor + Android App
Building a REST API in Kotlin made easy. Learn it in this video.Find my Ktor courses here (15% off with discount code ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just made one. Sorry for the delay, please check
1.4.0
Hi @rolfwessels
This bug has been fixed but not available yet. The latest release is from March 2020 while the bug has been fixed at May 2020. They still need to release a new version of the library including the bug fix.
Hi @e5l, any idea when the next release will be made?