Retrofit @get request sometimes It takes a long time to get the answer (10-15 sec.). I am only getting string data. on average 1-2 kb.
No problem when I send request from postman
What do you think is the problem?
RetrofitService.class;
private val okHttpClient = OkHttpClient().newBuilder()
.connectTimeout(20, TimeUnit.SECONDS)
.readTimeout(20, TimeUnit.SECONDS)
.writeTimeout(20, TimeUnit.SECONDS)
.build()
private val call = Retrofit.Builder()
.baseUrl(Constants.LINK)
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
.build().create(ApiEndpointRXJava::class.java)
fun getRetrofit(query: String, auth: String, queryList: List<String>): Single<List<ListModel>> {
return call.getRetrofit(query, auth, queryList)
}
Interface;
@GET(".../.../...")
fun getRetrofit(
@Query("query") query: String,
@Header("Authorization") authorization: String,
@Query("queryList") queryList: List<String>
): Single<List<ListModel>>
ViewModel.class;
fun getRetrofit(query: String, auth: String, queryList: List<String>) {
errorData.value = false
disposable.add(
retrofit
.getRetrofit(query, auth, queryList)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(object : DisposableSingleObserver<List<ListModel>>() {
override fun onSuccess(t: List<ListModel>) {
v.value = t
}
override fun onError(e: Throwable) {
e.value = true
}
})
)
}