Comments (8)
Hello, @jeremyforan.
Thank you for your suggestions.
I support the introduction of slog. I have experience using slog in another project, so I understand its benefits.
from appsync-client-go.
Hello @KazuhitoNakamura,
I will make a pull request. Also, I have made a small change for you to consider.
func (r *realtimeWebSocketOperation) readLoop() {
...
_, payload, err := r.ws.ReadMessage()
if err != nil {
if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
slog.Warn("connection timeout")
} else {
slog.ErrorContext(r.ctx, "error reading message", "error", err)
}
r.onConnectionLost(err)
return
}
We were getting intermittent "connection reset by peer" message. It looks like AWS is closing the session without warning. This would happen after a day or two of a single websocket being open. Because the error was not a timeout the onConnectionLost wasn't be called.
The change will always result in r.onConnectionLost(err) on a r.ws.ReadMessage() error. What do you think? Is there other considerations to be made here?
from appsync-client-go.
Thank you so much for your pull request, I have confirmed the pull request.
I don't think this change will result in the expected behavior since onConnectionLost is always called when a ReadMessage error occurs and is not limited to the error we want to resolve this time.
Is it possible to know the type of error that occurred this time?
from appsync-client-go.
It is difficult to capture the error as it is intermittent. It can take 2-3 days to occur. Currently we have a ticket open with AWS and they have escalated this issue to the AppSync team.
I tried using the syscall.ECONNRESET error type, based on this article https://gosamples.dev/connection-reset-by-peer/ but it did not seem to capture the error in testing:
if errors.Is(err, syscall.ECONNRESET) {
log.Print("This is connection reset by peer error")
}
Is there a efficient way to validate the connection is still valid? That way if there is an error we can check if the connection is still valid.
_, payload, err := r.ws.ReadMessage()
if err != nil {
if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
slog.Warn("connection timeout")
r.onConnectionLost(err)
return
} else {
// check if connection has been lost
slog.ErrorContext(r.ctx, "error reading message", "error", err)
r.onConnectionLost(err)
return
}
slog.Warn("error reading message", "error", err)
return
}
from appsync-client-go.
I apologize for the late reply.
Iām afraid, I'm not sure that way to check if connection has been lost for now.
I will read the source code to see if there are any errors that validate the connection has been broken.
To introduce slog ahead of time, could you remove this small change from the #31?
from appsync-client-go.
I agree with you.
I will push the changes as per your comment so that we can include the slog functionality. I will push the changes shortly.
from appsync-client-go.
I found it quite difficult to check if the connection was lost because there are several errors defined in errors.New().
- ReadMessage()
...
from appsync-client-go.
merge complete.
from appsync-client-go.
Related Issues (13)
- Does it support Authorisation mode IAM? i.e. IAM_AUTH HOT 10
- Websocket: Close 1006 (abnormal closure): unexpected EOF
- Set up AppSync credentials HOT 2
- How to authorize with API Key HOT 2
- Using API key instead of AWS credentials HOT 8
- Are there maintainers? HOT 2
- appsync.Client: Possibility to add a custom header to the requests HOT 4
- client_option - Allow using aws sdk v2 v4 signer HOT 5
- Switch connection error check from string check to error type check. HOT 1
- Subscription failing to start using WithIAMV2. HOT 11
- Silent Subscription Loss HOT 7
- Support for custom domains HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from appsync-client-go.