coder / coder/websocket

[chat example] How to simulate slow connection?

Open
#542 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
5.5k
Forks
376
PR merge metrics
No merged PRs in 30d

Description

I want to observe in what scenario `closeSlow` is called, How to simulate slow connection mentioned in [websocket/internal/examples/chat/chat.go](https://github.com/coder/websocket/blob/v1.8.14/internal/examples/chat/chat.go#L120-L127)?:
```
s := &subscriber{
msgs: make(chan []byte, cs.subscriberMessageBuffer),
closeSlow: func() {
mu.Lock()
defer mu.Unlock()
closed = true
if c != nil {
c.Close(websocket.StatusPolicyViolation, "connection too slow to keep up with messages")
}
},
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with internal/examples/chat/chat.go around lines 120-127 and trace the closeSlow callback through the chat example's subscriber behavior. Run the chat example while examining how messages reach the subscriber, then document a reproducible way to trigger the slow-connection condition and what result to expect.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
networking
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.