From 7d570ce148010e2cea4d9748a3474f4b2c15509a Mon Sep 17 00:00:00 2001 From: Heitor Date: Wed, 16 Aug 2023 22:48:57 -0300 Subject: [PATCH] websocket: handle error (#550) Co-authored-by: TwiN --- README.md | 2 +- core/endpoint.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e7ba3d39..89035b4c 100644 --- a/README.md +++ b/README.md @@ -1546,7 +1546,7 @@ endpoints: ``` The `[BODY]` placeholder contains the output of the query, and `[CONNECTED]` -shows whether the connected was successfully established. +shows whether the connection was successfully established. ### Monitoring an endpoint using ICMP By prefixing `endpoints[].url` with `icmp:\\`, you can monitor endpoints at a very basic level using ICMP, or more diff --git a/core/endpoint.go b/core/endpoint.go index b77352fa..866f1cd8 100644 --- a/core/endpoint.go +++ b/core/endpoint.go @@ -346,6 +346,10 @@ func (endpoint *Endpoint) call(result *Result) { } else if endpointType == EndpointTypeWS { result.Connected, result.Body, err = client.QueryWebSocket(endpoint.URL, endpoint.ClientConfig, endpoint.Body) result.Duration = time.Since(startTime) + if err != nil { + result.AddError(err.Error()) + return + } } else { response, err = client.GetHTTPClient(endpoint.ClientConfig).Do(request) result.Duration = time.Since(startTime)