Skip to content

Commit

Permalink
chore: Set default maximum message size for WebSocket connection
Browse files Browse the repository at this point in the history
  • Loading branch information
ksysoev committed Aug 20, 2024
1 parent 4c0c58a commit 131e203
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
// DefaultKeepAliveInterval is the default interval for sending ping requests to keep the connection alive.
defaultKeepAliveInterval = 25 * time.Second
defaultTimeout = 30 * time.Second
defaultMaxMessageSize = 1024 * 1024
)

// DerivAPI is the main struct for the DerivAPI client
Expand Down Expand Up @@ -161,6 +162,8 @@ func (api *Client) Connect() error {
return err
}

ws.SetReadLimit(defaultMaxMessageSize)

if resp.Body != nil {
defer resp.Body.Close()
}
Expand Down
2 changes: 1 addition & 1 deletion examples/tick_history/tick_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func main() {
End: "latest",
Start: &start,
Style: "ticks",
Count: 10})
Count: 5000})

if err != nil {
log.Fatal(err)
Expand Down

0 comments on commit 131e203

Please sign in to comment.