Comments (6)
If you're ok to work only with linux you can use epoll
see example number 4
https://github.com/eranyanay/1m-go-websockets
If you want it to be cross platform use libuv like libraries for go
This way the linux epoll will fire an event for on close, and you can handle all the connections and close events in a single go routin
with epoll + gobwas I successfully managed to achieve 1.5 million connections on 2 cores
from ws.
@hxt365 we implemented a watch dog mechanism with an in-memory cache to monitor idle connections and close them.
Briefly, On each request received we update timestamp for that descriptor and a garbage collector to close the idle connection.
from ws.
I can think a few ways:
https://golang.org/pkg/net/#TCPConn.SetKeepAlive
https://golang.org/pkg/net/#TCPConn.SetKeepAlivePeriod
https://golang.org/pkg/net/#TCPConn.SetDeadline
https://golang.org/pkg/net/#TCPConn.SetReadDeadline
https://golang.org/pkg/net/#TCPConn.SetWriteDeadline
https://godoc.org/github.com/gobwas/ws#NewPingFrame
https://godoc.org/github.com/gobwas/ws#NewPongFrame
https://godoc.org/github.com/gobwas/ws/wsutil#ControlHandler.HandlePing
https://godoc.org/github.com/gobwas/ws/wsutil#ControlHandler.HandlePong
Not sure which one will be more suited to you...
from ws.
@KromDaniel the problem is we don't receive close signal from the other side, we have many stalled connections which we dont receive any event for a long period, and for now we have a GC to detect those connections and close them, but i was wondering why just SetDeadline is not working on the connections with netpoll.Desc attached.
from ws.
Closing this for now, please reopen if question is still active.
from ws.
Hi, have you got a desire solution? if yes, can you share?
from ws.
Related Issues (20)
- Question: client example
- EOF error on ws.Upgrade HOT 8
- Is it necessary to use sync.Pool to reuse Reader Object in readData? HOT 1
- Read and Write timeouts? HOT 5
- Handshake.Extentions pointing to a buffer already returned to pbufio.ReaderPool
- State of the package and security updates HOT 6
- Websocket error on Safari HOT 4
- Dialer's Header parameter doesn't work as intended HOT 6
- Is WriteServerMessage thread-safe? HOT 9
- json decoder or unmarshaler? HOT 2
- Client-side example? HOT 5
- readme example problem HOT 1
- Correct way to handle continuation frame? HOT 1
- ReadFrame maxs out at 4096 lengths HOT 11
- RSV1 set, FIN not set on control using wsutil HOT 1
- Question - add headers during the upgrade HOT 2
- message rate limiter HOT 1
- Client disconnects on its own due to the 1008 error and EOF error. HOT 8
- Any example for using this library with `gnet`? HOT 5
- I encountered a problem of automatic disconnection after 30 seconds HOT 2
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 ws.