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

wsclient closed network connection err check #172

Conversation

phanidevavarapu
Copy link
Contributor

This PR is to fix the issue #163.
When we try to ReadMessage on a closed connection, will through net.ErrClosed error.

Tested this adding the following code
https://github.com/open-telemetry/opamp-go/blob/main/client/wsclient.go#L243
go func() { time.Sleep(5 * time.Second) c.Stop(ctx) }()

_, bytes, err := r.conn.ReadMessage()

time.Sleep(5 * time.Second)

This allowed to close connection while the receiveMessage is in progress.

@phanidevavarapu phanidevavarapu requested a review from a team June 21, 2023 02:51
@linux-foundation-easycla
Copy link

CLA Missing ID CLA Not Signed

@codecov
Copy link

codecov bot commented Jun 21, 2023

Codecov Report

Patch coverage: 90.00% and project coverage change: +0.38 🎉

Comparison is base (efddaa2) 76.11% compared to head (d71e9fd) 76.49%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #172      +/-   ##
==========================================
+ Coverage   76.11%   76.49%   +0.38%     
==========================================
  Files          24       24              
  Lines        1834     1868      +34     
==========================================
+ Hits         1396     1429      +33     
- Misses        326      327       +1     
  Partials      112      112              
Impacted Files Coverage Δ
client/types/callbacks.go 66.66% <ø> (ø)
server/httpconnection.go 33.33% <0.00%> (ø)
client/internal/mockserver.go 82.35% <85.71%> (+0.31%) ⬆️
server/serverimpl.go 58.92% <94.73%> (+0.37%) ⬆️
client/httpclient.go 95.00% <100.00%> (+0.26%) ⬆️
client/internal/httpsender.go 72.22% <100.00%> (+1.25%) ⬆️
client/internal/wsreceiver.go 91.89% <100.00%> (+0.46%) ⬆️
server/callbacks.go 68.18% <100.00%> (-4.55%) ⬇️
server/wsconnection.go 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@phanidevavarapu phanidevavarapu deleted the bugfix/ws-conn-close-err-check branch June 21, 2023 03:02
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.

1 participant