File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ const (
35
35
36
36
// Maximum size of the connection.send channel.
37
37
// When the channel is full, the hub closes it (see method hub.run).
38
- connectionChannelSize = 2048
38
+ connectionChannelSize = 256
39
39
)
40
40
41
41
type connection struct {
Original file line number Diff line number Diff line change 1
1
package sockets
2
2
3
+ import log "github.com/sirupsen/logrus"
4
+
3
5
// hub maintains the set of active connections and broadcasts messages to the
4
6
// connections.
5
7
type hub struct {
@@ -47,8 +49,15 @@ func (h *hub) run() {
47
49
select {
48
50
case conn .send <- m .msg :
49
51
default :
52
+
53
+ log .WithFields (log.Fields {
54
+ "context" : "websocket" ,
55
+ "user_id" : conn .userID ,
56
+ }).Error ("Connection send channel is full, connection closing" )
57
+
50
58
close (conn .send )
51
59
delete (h .connections , conn )
60
+ _ = conn .ws .Close () // Close the WebSocket connection first
52
61
}
53
62
}
54
63
}
You can’t perform that action at this time.
0 commit comments