tried with multiple ways still facing this issue as
I am using RxJava and Retrofit to do all my network operations. Below is my code.
<-- HTTP FAILED: java.net.SocketException: Socket closed
Service.kt
@GET("/v1/contact/{id}")
fun getContactDetails(@Path("id") id:String): Flowable<ContactDetailResponse>
AccountRepositoryImpl.kt
override fun contactDetails(contactId:String) {
mContactResponse.loading(true)
remote.getContactDetails(contactId)
.performOnBackOutOnMain(scheduler)
.subscribe({
data -> mContactResponse.success(data)
},{
error -> mContactResponse.failed(error)
})
.addTo(compositeDisposable)
}
Extentions.kt
fun <T> Flowable<T>.performOnBackOutOnMain(scheduler: Scheduler):
Flowable<T> {
return this.subscribeOn(scheduler.io())
.observeOn(scheduler.mainThread())
}
NetworkModule.kt
@Module
class NetworkModule(val key: String, val secret: String) {
@Provides
@Singleton
fun providesRetrofit(jacksonConverterFactory: JacksonConverterFactory,
rxJava2CallAdapterFactory:
RxJava2CallAdapterFactory,
okHttpClient: OkHttpClient,
baseUrl: String): Retrofit {
return Retrofit.Builder().baseUrl(baseUrl)
.addConverterFactory(jacksonConverterFactory)
.addCallAdapterFactory(rxJava2CallAdapterFactory)
.client(okHttpClient)
.build()
}
@Provides
@Singleton
fun providesOkHttpClient(cache: Cache, httpInterceptor:
HttpLoggingInterceptor): OkHttpClient {
val client = OkHttpClient.Builder()
.cache(cache)
.addInterceptor(httpInterceptor)
.retryOnConnectionFailure(true)
.connectTimeout(100, TimeUnit.SECONDS)
.writeTimeout(100, TimeUnit.SECONDS)
.readTimeout(100, TimeUnit.SECONDS)
return client.build()
}
}
yes getting response on postman
On your PC? Use a browser on your device. – XeroxcompositeDisposable
? – Duncandunce