question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Socket send timeout

See original GitHub issue

Hi, 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:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
john-lanticsecommented, Aug 15, 2019

Got stuck on this for awhile. Turns out some Emulator seems to have a problem with onFailure method.

1reaction
swankjessecommented, Mar 31, 2018

@zafrani try OkHttp 3.10.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found