Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a heartbeat mechanism, and timeouts support #53

Merged
merged 3 commits into from
Mar 8, 2019
Merged

Conversation

dunglas
Copy link
Owner

@dunglas dunglas commented Mar 5, 2019

Some reverse proxies kill connections after a (short) period of inactivity. Also, sometimes it's necessary to kill connections after some time to cleanup the memory.

This PR introduces new environment variables to start a heartbeat mechanism (that will prevent reverse proxies and some old browsers to kill the connection), and as well as read and write timeouts.

They are all disabled by default.

  • HEARTBEAT_INTERVAL: interval between heartbeats (useful with some proxies, and old browsers), set to 0s to disable (default), example 15s
  • READ_TIMEOUT: maximum duration for reading the entire request, including the body, set to 0 to disable (default), example: 2m
  • WRITE_TIMEOUT: maximum duration before timing out writes of the response, set to 0 to disable (default), example: 2m

@dunglas dunglas changed the title Add a hearthbeat mechanism, and timeouts support Add a heartbeat mechanism, and timeouts support Mar 6, 2019
@dunglas dunglas merged commit a65ad86 into master Mar 8, 2019
@dunglas dunglas deleted the heartbeat branch June 20, 2019 16:28
@karser
Copy link

karser commented Jul 25, 2019

@dunglas what do you think of setting HEARTBEAT_INTERVAL=30s by default? Heartbeat is required for both native and polyfill event source implementations.

Update: I see, the native EventSource uses keep-alive

@dunglas
Copy link
Owner Author

dunglas commented Jul 26, 2019

It sounds good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants