Comments (11)
I am looking at the problem right now, definitely reproducible, will create GitHub separate repo to show the call, my postman call to the same server do not have the error
from okhttp.
Also posted in #7794 (comment)
from okhttp.
If you can reproduce it against a private server, then you could post code for a repro, and privately message the actual host so we can investigate. Without that, this isn't actionable, and not clear it's not a problem with your client or server.
from okhttp.
have created a github repo and reproduced the error, https://github.com/jessicakfl/purplerain
stack trace here,
Installing profile for com.idigue.purplerain
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I request failed -> java.net.SocketTimeoutException: timeout
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okio.SocketAsyncTimeout.newTimeoutException(JvmOkio.kt:147)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okio.AsyncTimeout.access$newTimeoutException(AsyncTimeout.kt:158)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:337)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okio.RealBufferedSource.indexOf(RealBufferedSource.kt:427)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:320)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okhttp3.internal.http1.HeadersReader.readLine(HeadersReader.kt:29)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:179)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:111)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:95)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:84)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:65)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:205)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:537)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at java.lang.Thread.run(Thread.java:920)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I Caused by: java.net.SocketException: Socket closed
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at java.net.SocketInputStream.read(SocketInputStream.java:209)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at java.net.SocketInputStream.read(SocketInputStream.java:144)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okio.InputStreamSource.read(JvmOkio.kt:94)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:125)
2024-05-08 16:35:16.114 19514-19541 System.out com.idigue.purplerain I ... 20 more
the error not happen every time, the first time succeeded, log here,
2024-05-08 16:19:25.414 19204-19204 System.out com.idigue.purplerain I kotlin.Unit
2024-05-08 16:19:26.494 19204-19241 ProfileInstaller com.idigue.purplerain D Installing profile for com.idigue.purplerain
2024-05-08 16:19:28.217 19204-19234 System.out com.idigue.purplerain I insert user called ->
seems like a threading issue,
from okhttp.
the treading error when write called at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109), other than print out more debug log, please provide apis about the intercepter setup to bypass the error
from okhttp.
i'am using implementation("com.squareup.okhttp3:okhttp-android:5.0.0-alpha.11"), okio.RealBufferedSource in the package seems wrong version, at okio.RealBufferedSource.indexOf(RealBufferedSource.kt:427)
2024-05-08 19:08:50.759 19817-21076 System.out com.idigue.seashell I at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:320)
can't find at all
from okhttp.
Thanks for the repro, I'll dig in on the weekend. I really appreciate the effort to make it
from okhttp.
I realized ok is complicated and have extensive test coverage, would help with better documentation, might still not easy to reproduce on your end, will find out..
from okhttp.
think I found the problems when looking at ok trace, still have questions though, 1, in implementation("com.squareup.okhttp3:okhttp-android:5.0.0-alpha.11"),okio.RealBufferedSource has wrong version in the package
2, ok throw timeout error and failed the write request when server take the request without response, have changed server side return response 200, then no more errors, not sure why failed the whole request and not consistent result in threadings, wonder if it's intentional for ok
from okhttp.
That's great.
It sounds like OkHttp is doing the right thing, but sounds like you expect OkHttp to handle servers that don't return a response and just close the socket.
Some feedback on the repro, you might want to consider higher level libraries that build on OkHttp like retrofit or Ktor. they should simplify some of your code compared to the OkHttp callbacks.
from okhttp.
That's great.
It sounds like OkHttp is doing the right thing, but sounds like you expect OkHttp to handle servers that don't return a response and just close the socket.
Some feedback on the repro, you might want to consider higher level libraries that build on OkHttp like retrofit or Ktor. they should simplify some of your code compared to the OkHttp callbacks.
it is write request, server throw no error, postman calls success though, watch dog from time to time timeout the same socket call not very stable product, wonder if you had a look at my repo, hope it's correct recommended ok api callbacks
from okhttp.
Related Issues (20)
- Documentation: Clearly state that OkHttpClient should be a singleton HOT 6
- downloading big file midway Report an error java.net.ProtocolException: unexpected end of stream HOT 1
- Investigate Lock vs Synchronized performance HOT 4
- okhttp-coroutines in alpha 13 contains core classes HOT 1
- okhttp3.internal.http2.StreamResetException: stream was reset: CANCEL HOT 1
- HTTPS proxy support HOT 22
- Cannot instantiate MockWebServer on alpha 14: java.lang.NoClassDefFoundError: okhttp3/internal/_UtilJvmKt HOT 3
- Failing while building okhttp version parent-3.6.0 using mvn clean install HOT 1
- QUERY support
- No callbacks: no successful callbacks and no failed callbacks HOT 4
- TaskRunner's concurrent performance exhibits a significant decline in case of poor networks conditions HOT 19
- Calling response.body.string() on a MockWebServer response throws a SocketTimeoutException HOT 5
- UTF-32LE and UTF-32BE BOM are incorrect
- Huffman : Fatal Exception: java.lang.NullPointerException HOT 3
- Delayed sending request HOT 17
- Replace @Synchronized with ReentrantLock to avoid virtual thread pinning HOT 1
- How to solve two identical key values in response headers
- A suggestion for the removeEntry function in the DiskLruCache class
- OkHttp + HTTP2 + ExoPlayer (media3): only the first 16 MiB of audio data is audible HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from okhttp.