Git Product home page Git Product logo

Comments (6)

KromDaniel avatar KromDaniel commented on August 27, 2024 2

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.

ehsannm avatar ehsannm commented on August 27, 2024 1

@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.

navossoc avatar navossoc commented on August 27, 2024

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.

ehsannm avatar ehsannm commented on August 27, 2024

@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.

gobwas avatar gobwas commented on August 27, 2024

Closing this for now, please reopen if question is still active.

from ws.

hxt365 avatar hxt365 commented on August 27, 2024

Hi, have you got a desire solution? if yes, can you share?

from ws.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.