From c477b7cca6ae28be27c2d8a8ba4b1c0b102bd201 Mon Sep 17 00:00:00 2001 From: sacOO7 Date: Tue, 3 Sep 2024 16:53:04 +0530 Subject: [PATCH 1/3] Added code to check for active internet connection when setting up test sandbox --- ablytest/sandbox.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/ablytest/sandbox.go b/ablytest/sandbox.go index 469e47bd..8cfa804b 100644 --- a/ablytest/sandbox.go +++ b/ablytest/sandbox.go @@ -135,11 +135,29 @@ func NewSandbox(config *Config) (*Sandbox, error) { return NewSandboxWithEnv(config, Environment) } +// This code is copied from options.go +func hasActiveInternetConnection(httpClient *http.Client) bool { + res, err := httpClient.Get("https://internet-up.ably-realtime.com/is-the-internet-up.txt") + if err != nil || res.StatusCode != 200 { + return false + } + defer res.Body.Close() + data, err := io.ReadAll(res.Body) + if err != nil { + return false + } + return bytes.Contains(data, []byte("yes")) +} + func NewSandboxWithEnv(config *Config, env string) (*Sandbox, error) { + httpClient := NewHTTPClient() + if !hasActiveInternetConnection(httpClient) { + return nil, errors.New("internet is not available, cannot setup ably sandbox") + } app := &Sandbox{ Config: config, Environment: env, - client: NewHTTPClient(), + client: httpClient, } if app.Config == nil { app.Config = DefaultConfig() From ddb7eeadfe9b5813e9ba02af95a928bd1f46cef6 Mon Sep 17 00:00:00 2001 From: sacOO7 Date: Wed, 4 Sep 2024 13:04:34 +0530 Subject: [PATCH 2/3] Updated README#Proxy support section, added note for use of timeouts --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b56e1c92..d668d869 100644 --- a/README.md +++ b/README.md @@ -388,7 +388,8 @@ ably.WithHTTPClient(&http.Client{ }) ``` -**Important Note** - Connection reliability is totally dependent on health of proxy server and ably will not be responsible for errors introduced by proxy server. +**Important Note** - Connection reliability is totally dependent on health of proxy server and ably will not be responsible for errors introduced by proxy server. You may need to increase request timeouts in order to compensate for connection wait time period introduced by proxy server. +e.g use of `WithHTTPRequestTimeout`, `WithRealtimeRequestTimeout`. ## Note on usage of ablytest package Although the `ablytest` package is available as a part of ably-go, we do not recommend using it as a sandbox for your own testing, since it's specifically intended for client library SDKs and we don’t provide any guarantees for support or that it will remain publicly accessible. From eed0b83f9ec718a701f8ee388aa98a2293855b1f Mon Sep 17 00:00:00 2001 From: sacOO7 Date: Wed, 4 Sep 2024 13:05:25 +0530 Subject: [PATCH 3/3] Updated README for latest library specification --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d668d869..ecc788e7 100644 --- a/README.md +++ b/README.md @@ -433,11 +433,11 @@ Our [current approach to versioning](https://ably.com/documentation/client-lib-d ## Feature support -This library targets the Ably 1.2 [client library specification](https://ably.com/docs/client-lib-development-guide/features). List of available features for our client library SDKs can be found on our [feature support matrix](https://ably.com/download/sdk-feature-support-matrix) page. +This library targets the Ably 2.0.0 [client library specification](https://sdk.ably.com/builds/ably/specification/main/features/#CSV1). List of available features can be found on our [feature support matrix](https://sdk.ably.com/builds/ably/ably-go/main/features/) page. ## Known limitations -As of release 1.2.0, the following are not implemented and will be covered in future 1.2.x releases. If there are features that are currently missing that are a high priority for your use-case then please [contact Ably customer support](https://ably.com/support). Pull Requests are also welcomed. +As of latest release, the following features are not implemented and will be covered in future releases. If there are features that are currently missing that are a high priority for your use-case then please [contact Ably customer support](https://ably.com/support). Pull Requests are also welcomed. ### REST API