Comments (2)
Champion @JannikGM thank you. I'm taking a look at this now.
from websocket.
Nothing in the RFC seems to indicate any sane value for this. I don't know of any websocket extensions that need to be accounted for in any changes here.
It appears to me that this code is used in both client and server connections, so this probably is a more important function when it comes to clients being unable to write to the server.
Based on that information I think that the following actions should be taken:
- The default is documented as a warning
- Any examples should be updated to include setting this deadline to a sane standard
- This issue should be left open and marked for a v2 as changing this could be a nasty surprise for implementors that don't know about this
from websocket.
In the Go ecosystem, a zero value for deadline is usually taken to mean no deadline, not a deadline at the beginning of time. We know that's the intent here because the function sets the deadline on the network connection. A zero deadline on the network connection means no deadline.
A deadline in 41 days is not the same thing as no deadline, but it's a good approximation for most applications. Close the gap between what this package does and the expectations for deadlines by using the following code:
if deadline.IsZero() {
<-c.mu
} else {
d = time.Until(deadline)
if d < 0 {
return errWriteTimeout
}
select {
case <-c.mu:
default:
timer := time.NewTimer(d)
select {
case <-c.mu:
timer.Stop()
case <-timer.C:
return errWriteTimeout
}
}
}
With timeout of 41 days, it's unlikely that an application developer wrote code to rely on the undocumented timeout. It's not practical to test.
To trigger the 41 day timeout, another goroutine must be blocked for 41 days on write to the network connection. I'd expect the blocked write on a network connection to return an error before the 41 days elapses.
You will not break anything by updating to the code above. There will be no nasty surprises. You will not fix a problem that comes up in practice, but the code will be more correct and it will feel good to remove that weird constant from the code.
from websocket.
Related Issues (20)
- Module path not updated to github.com/gorilla/websocket/v2 and new tag does not follow semantic versioning HOT 2
- Websocket ping pong timeout HOT 2
- [BUG] Dialer type registered unconditionally into proxy
- Commits on branch release-1.5 are not useful
- golang.org/x/net is vendored in branch 1.5.1
- [BUG] Potential Handle Leak? HOT 1
- [Question] <traffic from local machine to websocket server is high> HOT 2
- [BUG] 1.5.1: use of closed network connection, 1.5.0 is fine HOT 4
- [BUG] 1.5.1 uses log.Printf HOT 14
- [FEATURE] Provide an override for `isValidChallengeKey` using a custom validator HOT 8
- Memory overflow; using ReadMessage() method
- [BUG] Clients get disconnected due to SetWriteDeadline and large workload HOT 4
- [question] error: RSV1 set, bad opcode 7, bad MASK HOT 10
- concurrent write to websocket connection HOT 2
- Documentation oversight after updating io/ioutl functions to io functions HOT 2
- WebSocket connection failure with Host header containing a space HOT 1
- Why does specifying the proxy address not work?
- [ISSUE] Handling SIGINT and SIGTERM for Graceful Shutdown in Go Websocket App HOT 2
- [BUG] 不能删除超时的连接 HOT 1
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 websocket.