Skip to content

Commit

Permalink
New default websocket reconnect backoff pattern (#478)
Browse files Browse the repository at this point in the history
new default backoff pattern for reconnect
  • Loading branch information
DnlLrssn committed May 22, 2024
1 parent 9774275 commit 84bbf4a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/settingup.md
Original file line number Diff line number Diff line change
Expand Up @@ -2533,7 +2533,7 @@ Settings specific to the `simple` scheduler.
* `instance`: Instance number for this instance. Use different instance numbers when running the same script in multiple instances to make sure the randomization is different in each instance. Defaults to 1.
* `reconnectsettings`: Settings for enabling re-connection attempts in case of unexpected disconnects.
* `reconnect`: Enable re-connection attempts if the WebSocket is disconnected. Defaults to `false`.
* `backoff`: Re-connection backoff scheme. Defaults to `[0.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0]`, if left empty. An example backoff scheme could be `[0.0, 1.0, 10.0, 20.0]`:
* `backoff`: Re-connection backoff scheme. Defaults to `[0.0, 2.0, 2.0, 2.0, 2.0, 2.0, 4.0, 4.0, 8.0, 12.0, 16.0]`, if left empty. An example backoff scheme could be `[0.0, 1.0, 10.0, 20.0]`:
* `0.0`: If the WebSocket is disconnected, wait 0.0s before attempting to re-connect
* `1.0`: If the previous attempt to re-connect failed, wait 1.0s before attempting again
* `10.0`: If the previous attempt to re-connect failed, wait 10.0s before attempting again
Expand Down
2 changes: 1 addition & 1 deletion generatedocs/data/params.json
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@
"Enable re-connection attempts if the WebSocket is disconnected. Defaults to `false`."
],
"reconnectsettings.backoff" : [
"Re-connection backoff scheme. Defaults to `[0.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0]`, if left empty. An example backoff scheme could be `[0.0, 1.0, 10.0, 20.0]`:",
"Re-connection backoff scheme. Defaults to `[0.0, 2.0, 2.0, 2.0, 2.0, 2.0, 4.0, 4.0, 8.0, 12.0, 16.0]`, if left empty. An example backoff scheme could be `[0.0, 1.0, 10.0, 20.0]`:",
"`0.0`: If the WebSocket is disconnected, wait 0.0s before attempting to re-connect",
"`1.0`: If the previous attempt to re-connect failed, wait 1.0s before attempting again",
"`10.0`: If the previous attempt to re-connect failed, wait 10.0s before attempting again",
Expand Down
2 changes: 1 addition & 1 deletion generatedocs/generated/documentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ var (
"randomaction.actions.weight": {"The probabilistic weight of the action, specified as an integer. This number is proportional to the likelihood of the specified action, and is used as a weight in a uniform random selection."},
"randomaction.iterations": {"Number of random actions to perform."},
"randomaction.thinktimesettings": {"Settings for the `thinktime` action, which is automatically inserted after every randomized action."},
"reconnectsettings.backoff": {"Re-connection backoff scheme. Defaults to `[0.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0]`, if left empty. An example backoff scheme could be `[0.0, 1.0, 10.0, 20.0]`:", "`0.0`: If the WebSocket is disconnected, wait 0.0s before attempting to re-connect", "`1.0`: If the previous attempt to re-connect failed, wait 1.0s before attempting again", "`10.0`: If the previous attempt to re-connect failed, wait 10.0s before attempting again", "`20.0`: If the previous attempt to re-connect failed, wait 20.0s before attempting again"},
"reconnectsettings.backoff": {"Re-connection backoff scheme. Defaults to `[0.0, 2.0, 2.0, 2.0, 2.0, 2.0, 4.0, 4.0, 8.0, 12.0, 16.0]`, if left empty. An example backoff scheme could be `[0.0, 1.0, 10.0, 20.0]`:", "`0.0`: If the WebSocket is disconnected, wait 0.0s before attempting to re-connect", "`1.0`: If the previous attempt to re-connect failed, wait 1.0s before attempting again", "`10.0`: If the previous attempt to re-connect failed, wait 10.0s before attempting again", "`20.0`: If the previous attempt to re-connect failed, wait 20.0s before attempting again"},
"reconnectsettings.reconnect": {"Enable re-connection attempts if the WebSocket is disconnected. Defaults to `false`."},
"reload.log": {"Save the reload log as a field in the output (`true` / `false`). Defaults to `false`, if omitted. **Note:** This should only be used when needed as the reload log can become very large."},
"reload.mode": {"Error handling during the reload operation", "`default`: Use the default error handling.", "`abend`: Stop reloading the script, if an error occurs.", "`ignore`: Continue reloading the script even if an error is detected in the script."},
Expand Down
2 changes: 1 addition & 1 deletion wsdialer/wsdialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const (

var (
// DefaultBackoff of reconnection
DefaultBackoff = []float64{0.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0}
DefaultBackoff = []float64{0.0, 2.0, 2.0, 2.0, 2.0, 2.0, 4.0, 4.0, 8.0, 12.0, 16.0}

closedChan = make(chan struct{}) // reusable closed channel
)
Expand Down

0 comments on commit 84bbf4a

Please sign in to comment.