Set read limit to 16 KB
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
a2c606b87d
commit
49f1b7aa14
2 changed files with 4 additions and 1 deletions
|
|
@ -29,7 +29,7 @@ const (
|
|||
pingPeriod = (pongWait * 9) / 10
|
||||
|
||||
// Maximum message size allowed from peer.
|
||||
maxMessageSize = 1024
|
||||
maxMessageSize = 16384 // 16 KB
|
||||
)
|
||||
|
||||
type HandleWebsocketMessage func([]byte) error
|
||||
|
|
|
|||
|
|
@ -113,8 +113,11 @@ func (w *Reader) Start() error {
|
|||
|
||||
func (w *Reader) printWebsocketToConsole() {
|
||||
defer w.Stop()
|
||||
w.writeMux.Lock()
|
||||
w.conn.SetReadLimit(maxMessageSize)
|
||||
w.conn.SetReadDeadline(time.Now().Add(pongWait))
|
||||
w.conn.SetPongHandler(func(string) error { w.conn.SetReadDeadline(time.Now().Add(pongWait)); return nil })
|
||||
w.writeMux.Unlock()
|
||||
for {
|
||||
_, message, err := w.conn.ReadMessage()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue