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.

Keep socket alive for a configured time

See original GitHub issue

Currently, if the ClientOption lazy is true, the websocket is closed as soon as there are no pending operations.

This adds a lot of overhead in case you have an application that is often sending queries or mutations since the client needs to re-establish the socket for every query/mutation.

It would be great if we could add a new keepalive parameter to ClientOptions that would control how long the socket should remain open after the last subscription has completed.

For instance:

export interface ClientOptions {
...
  /**
   * How long the client should wait, after the last query/mutation/subscription is completed, before closing the socket.
   *
   * @default 0 * 1000 (0 seconds)
   */
  keepalive?: number;
...
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
enisdenjocommented, Nov 12, 2020

Another enhancement I would like to suggest is to accept connectionParams to be a Promise or async function. I can open a separate enhancement request for this if you agree.

I agree! Please open another issue just for the sake of clarity and documentation.

1reaction
enisdenjocommented, Nov 12, 2020

A recipe would be a way, however… I spoke too soon.

@rpastro has actually a great point! I changed my mind, this would be indeed nice to have. Am already cooking up some code for this - bare with me. 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

2. TCP keepalive overview
The keepalive concept is very simple: when you set up a TCP connection, you associate a set of timers. Some of these timers...
Read more >
Does a TCP socket connection have a "keep alive"?
The short answer is yes there is a timeout enforced via TCP Keep-Alive, so no the socket won't remain open forever but will...
Read more >
TCP_KeepAlive socket option - IBM
The KEEPALIVEOPTIONS configuration value is used for timing unless a specific value has been provided through the TCP_KeepAlive option. The TCP_KeepAlive option ...
Read more >
Configuring TCP/IP keep-alives with EXTRA! to keep idle host ...
This article is about configuring client-side TCP/IP keep-alives with EXTRA! to keep an idle host session connected to the host.
Read more >
Custom Configuration of TCP Socket Keep-Alive Timeouts
Since the process doesn't start until a connection has been idle for two hours by default, stale TCP connections can linger for a...
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