Skip to content

Is rate limiting messages possible? #61

Open
@darienmiller88

Description

@darienmiller88

What's the best way to protect against someone on the front end simply using while(true){client.emit('i am spammer', true)} to flood my server with messages?

router := chi.NewRouter()
socketServer := socketio.NewServer(nil)
router.Use(httprate.LimitByIP(1, 5 * time.Second))//This only rate limits incoming client connections, not the client messages.

socketServer.OnConnect("/", func(c socketio.Conn) error {
        fmt.Println(c.ID() + ": connected")
        c.Join("public_chat")
        return nil
})

socketServer.OnEvent("/", "from_client", func(c socketio.Conn, message string) {
        fmt.Println(c.ID()+":", message)
})

router.Handle("/", socketServer)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions