okhttp

CompositeDisposable.clear causes OkHttp to throw java.lang.IllegalStateException: Unbalanced enter/exit

可紊 提交于 2020-01-11 10:08:06
问题 So I have a simple http request using OkHttp. I do this with RxJava on Android. I add this RxJava call to a CompositeDisposable that I then clear on onStop . For some reason that is triggering this exception below. I'm a little unsure about how to fix it. Caused by java.lang.IllegalStateException: Unbalanced enter/exit at okio.AsyncTimeout.enter(AsyncTimeout.java:73) at okio.AsyncTimeout$2.read(AsyncTimeout.java:235) at okio.RealBufferedSource.read(RealBufferedSource.java:47) at okhttp3

Correct way of setting up cache for OkHttp in Android

柔情痞子 提交于 2020-01-09 19:43:05
问题 I'm trying to set up the cache for OkHttp, so it only requests to the server the first time I try to retrieve a response from the server until the expires header date, or cache-control header that comes from the server invalidates the response from the cache. Currently, its caching the response, but not using it when requesting the resource again. May be this is not the way it was supposed to be used. I'm setting up OkHttpClient with cache like this: public static Cache createHttpClientCache

Android javax.net.ssl and FIPS compliance openSSL

放肆的年华 提交于 2020-01-07 07:43:08
问题 AFAIK Android javax.net.ssl classes uses openSSL/BoringSSL library at C/Low level for any SSL/TLS. Intention: Load FIPS compliance openSSL libaray in my application and make javax.net.ssl(okhttp) classes use the that library? Simlilar to WolfSSL provider,but its not JSSE compatible. is this feasible with FIPS openSSL+ android, what are configuration at android java level ? Thanks 回答1: This is untested because my Android toolchain is currently down, but I believe that you should be able to

OkHttp trigger callback in originated class after finishing network actions

情到浓时终转凉″ 提交于 2020-01-06 20:57:39
问题 Here is the scenario: I have an Activity, named MainActivity , calling a OkHttp wrapper class, named NetworkManager to perform network post in background: // In MainActivity NetworkManager manager = new NetworkManager(); try { manager.post("http://www.example.com/api/", reqObj); // reqObj is a JSONObject } catch(IOException ioe) { Log.e(TAG, ioe.getMessage()); } Then, in the NetworkManager , I perform the POST action in asynchronous mode: public class NetworkManager { static String TAG =

Handle exceptions thrown by a custom okhttp Interceptor in Kotlin Coroutines

元气小坏坏 提交于 2020-01-05 03:32:29
问题 I'm using a custom Interceptor along with Retrofit client in my Android app, that throws an Exception under some specific circumstances. I'm trying to make it work using Kotlin coroutines. The problem is that I'm unable to handle the before mentioned error, since in the moment the exception is thrown from within the Interceptor instance, it crashes the whole app instead of being caught in the coroutine's try/catch statement. While I was using the Rx implementation, the exception was

Android Retrofit + GSON - Enum serialization for API calls - Annoying extra quotation marks added

最后都变了- 提交于 2020-01-05 03:07:31
问题 This problem (this might be by design, who knows - not simple to find a clear answer, at any rate) occurs in both Android Retrofit 1.9 and 2.0, and with the latest GSON library. I have an Enum class like such: public enum SomethingType { @SerializedName("first") First, @SerializedName("second") Second } And using Retrofit (2.0, but same issue with 1.9) along with GSON, I attempt to output the enum instance as such: @Multipart @POST("things") Call<ThingResponse> createThing( @Part("image")

Gradle error - could not download okhttp.jar file 2.7.2

耗尽温柔 提交于 2020-01-05 02:10:13
问题 when i added the firebase functions library (implementation 'com.google.firebase:firebase-functions:16.1.0') , android studio(3.1.4) throws " Unable to resolve dependency for ':app@debug/compileClasspath': Could not download okhttp.jar (com.squareup.okhttp:okhttp:2.7.2) " I tried to add " implementation files('libs/okhttp-2.7.2.jar') " but still got the same error. this is my build.gradle(app) apply plugin: 'com.android.application' android { compileSdkVersion 27 buildToolsVersion '27.0.3'

Android connection with ESP8266 on One Plus ( Android 6.0.1)

≯℡__Kan透↙ 提交于 2020-01-04 09:36:35
问题 Retrofit on Android 6.0 has a problem making Http calls after connecting to Access Point Steps to reproduce: Connect to Esp8266 Access Point Make an http call to http://192.168.4.1 (Default gateway of esp8266 accesspoint) The IP address of WIFI is 192.168.4.2 It throws the below exception I have tried the same on Android 5.1 and the same code works flawlessly java.net.SocketException: socket failed: ENONET (Machine is not on the network) at libcore.io.IoBridge.socket(IoBridge.java:619) at

OkHTTP Websocket: Unexpected end of steam on Connection

删除回忆录丶 提交于 2020-01-03 19:16:14
问题 I'm trying to connect to the Stack Exchange chat Websocket. The websocket is used to receive new events in the chat, such as new messages. Here's the code used to create the Websocket: String wsUrl = getWsUrl(); Request wsRequest = new Request.Builder() .url(wsUrl) .build(); WebSocketCall wsCall = WebSocketCall.create(httpClient, wsRequest); wsCall.enqueue(new ChatWebSocketListener()); The websocket URL is in this form: wss://chat.sockets.stackexchange.com/events/16

OkHTTP Websocket: Unexpected end of steam on Connection

心已入冬 提交于 2020-01-03 19:15:53
问题 I'm trying to connect to the Stack Exchange chat Websocket. The websocket is used to receive new events in the chat, such as new messages. Here's the code used to create the Websocket: String wsUrl = getWsUrl(); Request wsRequest = new Request.Builder() .url(wsUrl) .build(); WebSocketCall wsCall = WebSocketCall.create(httpClient, wsRequest); wsCall.enqueue(new ChatWebSocketListener()); The websocket URL is in this form: wss://chat.sockets.stackexchange.com/events/16