Skip to content

Commit

Permalink
ws: testing unstable connection(s) between client and server
Browse files Browse the repository at this point in the history
  • Loading branch information
norwnd committed Feb 8, 2025
1 parent ed25bd4 commit 90214e3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions client/comms/wsconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"encoding/json"
"errors"
"fmt"
"math/rand"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -259,6 +260,11 @@ func (conn *wsConn) connect(ctx context.Context) error {
dialer.Proxy = http.ProxyFromEnvironment
}

// TODO
if rand.Intn(3) != 0 {
return fmt.Errorf("DUMMY CONNECT ERRRRRRR")
}

ws, _, err := dialer.DialContext(ctx, conn.url(), conn.cfg.ConnectHeaders)
if err != nil {
if isErrorInvalidCert(err) {
Expand Down Expand Up @@ -440,6 +446,12 @@ func (conn *wsConn) read(ctx context.Context) {
return
}

// TODO
if rand.Intn(40) == 0 {
conn.handleReadError(fmt.Errorf("DUMMY READ ERRRRRR"))
return
}

// If the message is a response, find the handler.
if msg.Type == msgjson.Response {
handler := conn.respHandler(msg.ID)
Expand Down

0 comments on commit 90214e3

Please sign in to comment.