4,474 questions
Advice
0
votes
0
replies
39
views
OkHttp ConnectionPool - How to set the maximum lifetime of connections in the pool (TTL)
Using OkHttp 5.3.2, how can I set the maximum time a connection is allowed to stay in the ConnectionPool, so that e.g. after 30 seconds a connection is closed and removed from the pool (after the ...
3
votes
0
answers
126
views
Android-Retrofit: getting escaped double-quoted JSON
I'm having problems receiving a JSON response from a REST endpoint using Retrofit. Some of the requests return JSON with a bunch of null characters and escaped double quotes.
Pasted from Android ...
-1
votes
1
answer
204
views
java.lang.ClassNotFoundException: okio.Buffer when using OkHttp inside Eclipse plugin (OSGi)
I am developing an Eclipse plugin (OSGi environment) and trying to use OkHttp 4.11.0 to send HTTP requests. However, I get the following runtime error:
java.lang.ClassNotFoundException: okio.Buffer ...
2
votes
0
answers
128
views
OkHttpClient Client not sending server-name extension in SSL Client handshake
I have a Springboot server with two ssl self signed certificates configured for different hostnames. One certificate assigned to hostname localhost. Another assigned as fallback, so any hostname other ...
0
votes
1
answer
130
views
Authenticated Socks5 With OkHttpClient
Been spending hours trying to get OkHttpClient to work with a proxy. My proxy supports socks5, https. I cannot get it to work on either. I've now spent hours trying different work arounds from years ...
3
votes
1
answer
1k
views
Android project throws FileAnalysisException in onCreate method in Main Activity when adding OkHttp library
I've created an Empty Views Activity project in Android Studio, but as soon as I add the dependency in build.gradle.kts and try to launch the app, it throws an exception (see output). No code is ...
1
vote
1
answer
112
views
Do OkHttpClient instances created with newBuilder() from common client share the same pools?
According to the docs of OkHttpClient, it is better to use a single shared instance.
In my case I need a client for HTTP requests and a client for WebSocket connections; both have different ...
0
votes
0
answers
76
views
How to initialize Android OkHttp cache interceptor config at app start without blocking the main thread (Hilt + Coroutines)?
I have a CacheCreation class that prepares config for an OkHttp interceptor. It’s created during DI on app launch, and we currently use runBlocking so the object graph is ready before the first ...
-1
votes
1
answer
170
views
Spring Boot 4.0.0-M1 java.lang.NoClassDefFoundError: Could not initialize class io.opentelemetry.exporter.sender.okhttp.internal.OkHttpGrpcSender
I would like to build a native image with the newly released (as of this writing) Spring Boot 4.0.0-M1 and GraalVM AOT
With this code:
@Configuration
public class TracingConfiguration {
@Bean
...
0
votes
1
answer
76
views
I got java.io.FileNotFoundException when I call URL.openStream()
I have an URL for file downloading and it works perfectly on my Samsung Galaxy S10 (running Android 12), but the same app throws java.io.FileNotFoundException on my Google Pixel 9 with the latest ...
4
votes
1
answer
2k
views
How to setup OkHttp v5 with Maven?
OkHttp recently received a v5 update, meaning there are breaking changes.
I've noticed these breaking changes, as my project no longer recognizes OkHttp or any of its classes.
Unfortunately is the ...
0
votes
1
answer
190
views
Websockets Ktor/OkHTTP server sends ping, doesn't receive pong
I implemented a basic websockets server, following the instructions on the Ktor site (server, client).
Server (complete source):
webSocket("/echo") {
send("Please enter your name&...
1
vote
2
answers
232
views
How to decide whether to use chunked upload in OkHttp or not?
I am uploading files to WebDav servers using
RequestBody requestBody = new MultipartBody.Builder()
.addPart(RequestBody.create(data, MediaType.parse("application/...
1
vote
1
answer
129
views
OkHttpClient throws IllegalStateException when server responds with 100-Continue
OkHttpClient version 4-12.0 sends multipart-form request using default configuration ; Sever responds with 100-Continue . After receiving couple of 100-Continue OkHttpClient fails with ...
1
vote
1
answer
124
views
Python flask server 405 error for a specific path when hosted on Azure, works fine locally
I'm building a flask app to process images uploaded from a mobile device, before sending results back to the mobile app. I've successfully deployed the flask app on Azure, and can confirm it works ...
2
votes
2
answers
2k
views
CertPathValidatorException: Trust anchor for certification path not found (Android 15 and below)
We recently switched from HttpUrlConnection to OkHttp (v4.12.0) on Android and started seeing CertPathValidatorException: Trust anchor for certification path not found from a small percentage of our ...
1
vote
0
answers
144
views
Java okhttp3 Exceptions
My Spring Boot uses okhttp3 to send HTTP requests as a client. I have no control over the servers. (But I can ask server team to change the settings if needs be.)
<dependency>
<groupId>...
0
votes
0
answers
105
views
OkHttp client timeout does not work when using NLB (Network Load Balancer)
I’m facing an issue where the OkHttp client timeout doesn't work as expected.
Conditions:
About the Program:
java client (Feign) generated using OpenAPI Generator.
Using OkHttp 3 client.
Flow:
myapp-...
0
votes
2
answers
752
views
okhttp websocket immediately fails after connection
I've been tryin to get websockets working in my Android app. I am using OKhttp websockets, an apache proxy and a node server. I finally got a connection, but it connects and then within a few seconds ...
0
votes
1
answer
146
views
MockWebServer start on Android API 35 cause
I have an app on API 34 that runs MockWebServer for the tests.
Mockweberser is triggered only for tests that are mocked.
Mockweberser class inits on port 8080
class MockedkWebServer {
...
init {
...
0
votes
1
answer
128
views
In OkHttp what is the difference between response.close() and response.body.close()?
I am working with OkHttp for my connections. To avoid memory leaks by closing responses. But the docs and none of the information I found explains which close to use.
Here are the difference close ...
1
vote
1
answer
578
views
Android Studio cannot resolve symbol OkHttpClient
I'm trying to use OkHttpClient in Android Studio 4.1.3 and I'm getting the error "Cannot resolve symbol 'OkHttpClient'".
I've found a number of posts for this problem but none solve my issue....
1
vote
0
answers
78
views
Android Glide + okHttp -- Some users experience very slow image loading and network speeds on wifi, but no problems on mobile data
I am experiencing a weird issue that only affects some of my users (and unfortunately not my own devices).
On wifi, when loading up resources, the data will take AGES to download. But then the user ...
1
vote
1
answer
617
views
Can you enqueue responses within the dispatcher for MockWebServer?
I'm writing tests for my webserver, and I'm making use of MockWebServer (okhttp3.mockwebserver) to mock the responses. As I understand it from the documentation, there are broadly 2 ways to do this:
...
0
votes
0
answers
98
views
OKHTTP taking too long to send a request with a 92MB "attachment"
I'm using OKHTTP 4.10.0 to send requests from my Android App to my back-end.
The problem raises when I add a 92MB file to my request. When I add this file, OKHTTP takes about 1min to send the request ...
0
votes
1
answer
39
views
How call Authenticator.authenticate with custom respond in okhttp?
Request process
request:
url:http://host/test
method: post
body:{"token":"AAA"}
if token is invalid respond:
{"code":401,"msg":"unauth"}
Now,I hope ...
0
votes
0
answers
70
views
How to replace/change a URL if a request fails
I want to change the URL of my request after it fails once. Let me elaborate...
So if I made a call to www.abc.com/whatever and for some reason this call fails (maybe because of HTTP exception, ...
1
vote
1
answer
71
views
Unable to connect to API with TLS 1.2 on Android 4.x devices (no Google Play Services)
I'm having trouble connecting to my API on Android 4.x devices after removing TLS 1.1 support. While updating the OkHttpClient configuration has been successful for devices with API level 21 and above,...
1
vote
0
answers
39
views
OkHttp first call to execute method returns unreadable characters
On first call
▼♦
??{"value":[]}??☺??B?@D
All subsequent calls are processed correctly
{"value":[]}
Request code
Request request = new Request.Builder()
.url(...
4
votes
1
answer
2k
views
"Cannot resolve com.squareup.okhttp3:mockwebserver:unknown" error after upgrade to Spring Boot 3.4.0
After upgrade to Spring Boot 3.4.0 from 3.3.x, I get an error
Cannot resolve com.squareup.okhttp3:mockwebserver:unknown
My project uses okhttp3.mockwebserver.MockWebServer and has the dependency
<...
0
votes
1
answer
109
views
Extrcating Body Request. ( Data Exfiltration Detection )
I am working on a detecting data exfiltration for am android malware. I noticed it makes some post request to the server. I have downloaded the AOSP and modified the Request.java and HttpEngine.java (...
0
votes
1
answer
73
views
No Response When Refreshing Token in Retrofit with OkHttp
I am facing an issue with the token refresh mechanism in my Android application using Retrofit and OkHttp. The following code is designed to intercept API requests, add an access token to the request ...
1
vote
1
answer
1k
views
How do I avoid a socket timeout with Spring AI ImagePrompt?
I have the following in my controller...
@GetMapping("/openai/image")
public String generate(@RequestParam(value = "message") String message) {
ImageOptions options ...
0
votes
0
answers
76
views
okhttp client's callTimeout not respected
My Java project uses okhttp3 version 4.2.0.
I set callTimeout 400ms for client, but when I watch online server log, that request gets cancelled after 34606ms
Btw, when this happens, the cpu load is ...
0
votes
1
answer
75
views
java.lang.IllegalStateException: Unexpected default trust managers in OkHttp3 and Retfrofit when minifyEnabled
I'm facing an issue when using OkHttp3 with minifyEnabled (R8) in my Android app. With R8 enabled, I encounter the following runtime error:
java.lang.IllegalStateException: Unexpected default trust ...
1
vote
0
answers
135
views
How can I log pings in OkHttpClient when setting pingInterval?
I use OkHttpClient as a WebSocket client. I set pinging every 10 seconds:
private val okHttpClient = OkHttpClient.Builder()
.pingInterval(10, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit....
2
votes
1
answer
127
views
Custom cache OkHttp
I'd like to cache API request in my app so that user could see something even if they are offline.
I also have a HeaderInterceptor with multiple headers, such as language such as en, es, fr etc... The ...
-1
votes
1
answer
166
views
Could not locate class file for okhttp3.OkHttpClient with ByteBuddy android
previously i asked the question here, got some suggestions from @Rafael Winterhalter. i applied those changes but stuck with new error.
this code is working with subclass but I want to replace all the ...
1
vote
1
answer
139
views
OkHttp MockWebServer dispatch not getting triggered
Here's my code in isolation
fun getMockServerUrl(): String {
val server = MockWebServer()
server.dispatcher = object : Dispatcher() {
override fun dispatch(request: RecordedRequest): ...
1
vote
3
answers
133
views
Kotlin Android Crashes when the OkHttp Request is created
I have created a Module for Network calls.
It works well when tested on the same Project for all API methods.
But When I add it as a dependency on another project it fails When a request is created.
...
4
votes
1
answer
327
views
Stack trace doesn’t point to the origin of API call when throwing an exception with Retrofit
I am using Retrofit, OkHttp, Kotlin coroutines to make HTTP requests.
When the server returns an unsuccessful result (e.g., 404), I throw a custom exception, which is a subtype of IOException.
The ...
1
vote
0
answers
72
views
Android: cellular network affects socket read_buffer_size of WiFi connections
I am investigating an issue where Wi-Fi transfers between my android app and GoPro are inconsistent across different cellular network conditions.
Initially, I noticed that GoPro Quik (Official GoPro ...
3
votes
0
answers
136
views
Android – okhttp NullPointerException on Cookie.name()
Lately I started getting an exception in production, where the app complains about a NullPointerException when trying to access an okhttp's Cookie instance. We can't reproduce it, and it's quite ...
-1
votes
1
answer
80
views
Android post request does not have application/json body
I m training with http request via android client and a server, using Okhttp3 module. I already used get request with no problems, but when I try post request they don't reach the server.
Using some ...
0
votes
1
answer
67
views
Android app client can't connect to my server
I created a client and a server to train my self with POST request. That was in java windows program, and I had no problem, it was fully functional. Now I m trying to create an android version to have ...
0
votes
1
answer
138
views
How to get Optum sandbox to authenticate with OAuth 2.0 using Java and okhttp
I am trying to get a Java application that uses okhttp to properly authenticate with the Optum API, as documented here. Although I can get a proper response from a test tool, I can not get a proper ...
1
vote
0
answers
66
views
How to add cards to a fragment on network response in Android
I am new to Android and looking for some help. I am making a get request which returns a list as a string. For each entry in this list I want to add a card to a linearLayout in a horizontal scrollview ...
0
votes
0
answers
249
views
InterruptedIOException from OKHTTP client post java upgrade to 21 and Spring boot 3.3
We recently updated our APIs with Java 21(Eclipse Temurin; open JDK) and with Spring Boot 3.3. And also enabled the virtual threads
spring.threads.virtual.enabled=true
After this, we continuously get ...
0
votes
1
answer
70
views
Run Android tests in Azure: Type mismatch: inferred type is () -> String? but String? was expected
When I run the Azure pipeline of my Android project to run the tests, during the test step two gradle tasks fail, compileDebugKotlin and compileReleaseKotlin, with the error in the title, pointing ...
1
vote
2
answers
1k
views
Steps to add okhttp to existing Java project in Eclipse
I'm old-school and so have always just added jar files to the build path in Eclipse (4.26.0), but I want to modernize. Everything I see talks about maven, so I went into Window > Show View > ...