SetReadLimit sets the max number of bytes to read for a single message. It applies to the Reader and Read methods. By default, the connection has a message read limit of 32768 bytes. When the limit is hit, reads return an error wrapping ErrMessageTooBig and the connection is closed with StatusMess
(n int64)
| 95 | // |
| 96 | // Set to -1 to disable. |
| 97 | func (c *Conn) SetReadLimit(n int64) { |
| 98 | if n >= 0 { |
| 99 | // We read one more byte than the limit in case |
| 100 | // there is a fin frame that needs to be read. |
| 101 | n++ |
| 102 | } |
| 103 | |
| 104 | c.msgReader.limitReader.limit.Store(n) |
| 105 | } |
| 106 | |
| 107 | const defaultReadLimit = 32768 |
| 108 |
no outgoing calls