Socket send timeout
See original GitHub issueHi, i have created a socket connection inside a service using:
OkHttpClient client = new OkHttpClient.Builder()
.readTimeout(3000, TimeUnit.MILLISECONDS)
.writeTimeout(3000, TimeUnit.MILLISECONDS)
.connectTimeout(3000, TimeUnit.MILLISECONDS)
.build();
Request request = new Request.Builder().addHeader(Config.WEBSOCKET_PARAM_COOKIE, "access_token=" + userToken)
.url(mySocketUrl)
.build();
webSocket = client.newWebSocket(request, websocketListener);
Everything works fine, but now i’m trying to simulate a no connection scenario. I have turned on the airplane mode, while in a chat, and tryied to send a message using .send(String). I through that it would fire some kind of exception or the onFailure/onClosed methods, but none of them are called. How can i detect if the .send function really worked? Thanks in advance.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:18 (8 by maintainers)
Top Results From Across the Web
Using timeouts on socket send() and recv() - Stack Overflow
If all you need is a timeout on a single socket then you can use setsockopt() with the SO_RCVTIMEO option to allow a...
Read more >Socket.SendTimeout Property - Microsoft Learn
Gets or sets a value that specifies the amount of time after which a synchronous Send call will time out.
Read more >Socket Timeout — An Important and Sometimes Complicated ...
During my experience working with Python, I've had several cases where a network client was left hanging while trying to request a server....
Read more >socket — Low-level networking interface — Python 3.11.1 ...
This makes it easy to write clients that are compatible to both IPv4 and IPv6. Passing the optional timeout parameter will set the...
Read more >When TCP sockets refuse to die - The Cloudflare Blog
The default value of 15 yields a hypothetical timeout of 924.6 seconds and is a lower bound for the effective timeout. TCP will...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Got stuck on this for awhile. Turns out some Emulator seems to have a problem with onFailure method.
@zafrani try OkHttp 3.10.