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

feat: count ping as websocket activity #203

Merged
merged 2 commits into from
Jul 31, 2024

Conversation

denopink
Copy link
Contributor

  • count ping as websocket activity
  • lack of activity will trigger inactivityTimeout, causing the websocket connection to close and reconnect

- count ping as websocket activity
- lack of activity will trigger inactivityTimeout, causing the websocket connection to close and reconnect
@denopink denopink added the enhancement improvement or small functionality added to an existing feature label Jul 31, 2024
@denopink denopink requested review from schmidtw and johnabass July 31, 2024 20:58
@denopink denopink self-assigned this Jul 31, 2024
Copy link

codecov bot commented Jul 31, 2024

Codecov Report

Attention: Patch coverage is 81.81818% with 4 lines in your changes missing coverage. Please review.

Project coverage is 77.01%. Comparing base (850efb6) to head (f278cca).

Files Patch % Lines
internal/websocket/ws.go 81.81% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #203      +/-   ##
==========================================
+ Coverage   76.97%   77.01%   +0.04%     
==========================================
  Files          75       75              
  Lines        4542     4550       +8     
==========================================
+ Hits         3496     3504       +8     
  Misses        848      848              
  Partials      198      198              
Flag Coverage Δ
unittests 77.01% <81.81%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -289,22 +291,32 @@ func (ws *Websocket) run(ctx context.Context) {
// Read loop
for {
var msg wrp.Message
ctx, cancel := context.WithTimeout(ctx, ws.inactivityTimeout)
typ, reader, err := ws.conn.Reader(ctx)
Copy link
Contributor Author

@denopink denopink Jul 31, 2024

Choose a reason for hiding this comment

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

we want to include the activity from pings. that requires us to manually trigger a timeout.

Otherwise, the device will reconnect in intervals of ws.inactivityTimeout

Copy link

@johnabass johnabass left a comment

Choose a reason for hiding this comment

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

that looks good!

@denopink denopink enabled auto-merge July 31, 2024 22:19
@denopink denopink merged commit 31387eb into main Jul 31, 2024
16 checks passed
@denopink denopink deleted the denopink/feat/ws-count-pings-as-activity branch July 31, 2024 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement improvement or small functionality added to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants