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

Use TCP keepalive probes to detect local log stream closing #1220

Merged
merged 2 commits into from
May 14, 2019

Conversation

CameronDiver
Copy link
Contributor

Change-type: patch
Closes: #1219
Signed-off-by: Cameron Diver [email protected]


Contributor checklist
  • Introduces security considerations
  • Affects the development, build or deployment processes of the component

package.json Outdated
@@ -153,6 +154,7 @@
"moment": "^2.24.0",
"moment-duration-format": "^2.2.1",
"mz": "^2.6.0",
"net-keepalive": "^1.2.1",
Copy link
Contributor

@pdcastro pdcastro May 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From https://www.npmjs.com/package/net-keepalive:

The Missing (TCP_KEEPINTVL and TCP_KEEPCNT) SO_KEEPALIVE socket option setters and getters for Node using ffi module. Tested on linux, should work on osx and freebsd.

I think it is OK for this feature/fix to apply to Linux only (maybe macOS). The question is: does it raise any errors when it is run on Windows? Because raising errors would be a problem. :-)

Copy link
Contributor

@hedss hedss May 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, in Windows 10, this should work as expected as the setsockopt() includes both TCP_KEEPINTVL and TCP_KEEPCNT (which is what the underlying library uses), see here. However, in prior versions, these were set as registry keys and will simply be ignored.

I don't think this'll throw an error, but it's probably worth checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I initially misread it to support the 3 big ones, testing on a windows vm now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module isn't supported on windows. Will merge this try to find a method of achieving the same thing on Windows.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CameronDiver, your laptop runs Linux, right? I offer to test it on macOS, just in case. I've tried it now, but it's failing for other reasons. I'll try again when the build tests are passing.

@CameronDiver CameronDiver force-pushed the 1219-tcp-keepalive branch 4 times, most recently from 5250099 to 96c975d Compare May 14, 2019 10:37
Cameron Diver added 2 commits May 14, 2019 11:39
Change-type: patch
Closes: #1219
Signed-off-by: Cameron Diver <[email protected]>
Change-type: patch
Signed-off-by: Cameron Diver <[email protected]>
Copy link
Contributor

@pdcastro pdcastro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed to work on macOS 10.14.4:

$ ./bin/balena-dev logs 192.168.1.111
[Logs]    [2019-5-14 13:17:57] Removing volume 'resin-data'
[Error]   Connection to device lost

@CameronDiver CameronDiver merged commit eaa886c into master May 14, 2019
@CameronDiver CameronDiver deleted the 1219-tcp-keepalive branch May 14, 2019 12:23
thgreasi added a commit that referenced this pull request Apr 9, 2024
Since node 12.17.0 setKeepAlive also sets
TCP_KEEPCNT=10 (vs 5 that we had)
TCP_KEEPINTVL=1 (vs 5s that we had)

Change-type: patch
See: https://nodejs.org/docs/latest-v14.x/api/net.html#net_socket_setkeepalive_enable_initialdelay
See: #1220
thgreasi added a commit that referenced this pull request Apr 9, 2024
Since node 12.17.0 setKeepAlive also sets
TCP_KEEPCNT=10 (vs 5 that we had)
TCP_KEEPINTVL=1 (vs 5s that we had)

Change-type: patch
See: https://nodejs.org/docs/latest-v14.x/api/net.html#net_socket_setkeepalive_enable_initialdelay
See: #1220
thgreasi added a commit that referenced this pull request Apr 9, 2024
Since node 12.17.0 setKeepAlive also sets
TCP_KEEPCNT=10 (vs 5 that we had)
TCP_KEEPINTVL=1 (vs 5s that we had)

Change-type: patch
See: https://nodejs.org/docs/latest-v14.x/api/net.html#net_socket_setkeepalive_enable_initialdelay
See: #1220
thgreasi added a commit that referenced this pull request Apr 9, 2024
Since node 12.17.0 setKeepAlive also sets
TCP_KEEPCNT=10 (vs 5 that we had)
TCP_KEEPINTVL=1 (vs 5s that we had)

Change-type: patch
See: https://nodejs.org/docs/latest-v14.x/api/net.html#net_socket_setkeepalive_enable_initialdelay
See: #1220
thgreasi added a commit that referenced this pull request Apr 9, 2024
Since node 12.17.0 setKeepAlive also sets
TCP_KEEPCNT=10 (vs 5 that we had)
TCP_KEEPINTVL=1 (vs 5s that we had)

Change-type: patch
See: https://nodejs.org/docs/latest-v14.x/api/net.html#net_socket_setkeepalive_enable_initialdelay
See: #1220
thgreasi added a commit that referenced this pull request Apr 9, 2024
Since node 12.17.0 setKeepAlive also sets
TCP_KEEPCNT=10 (vs 5 that we had)
TCP_KEEPINTVL=1 (vs 5s that we had)

Change-type: patch
See: https://nodejs.org/docs/latest-v14.x/api/net.html#net_socket_setkeepalive_enable_initialdelay
See: #1220
thgreasi added a commit that referenced this pull request Apr 9, 2024
Since node 12.17.0 setKeepAlive also sets
TCP_KEEPCNT=10 (vs 5 that we had)
TCP_KEEPINTVL=1 (vs 5s that we had)

Change-type: patch
See: https://nodejs.org/docs/latest-v14.x/api/net.html#net_socket_setkeepalive_enable_initialdelay
See: #1220
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.

balena logs command should use a keepalive for local devices
4 participants