Skip to content

Commit 6bcf832

Browse files
authored
Merge pull request #653 from ably/feature/proxy-support
Proxy support
2 parents 9597052 + 60418e4 commit 6bcf832

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

README.md

+37
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,43 @@ client, err = ably.NewRealtime(
353353
)
354354
```
355355

356+
## Proxy support
357+
The `ably-go` SDK doesn't provide a direct option to set a proxy in its configuration. However, you can use standard environment variables to set up a proxy for all your HTTP and HTTPS connections. The Go programming language will automatically handle these settings.
358+
359+
### Setting Up Proxy via Environment Variables
360+
361+
To configure the proxy, set the `HTTP_PROXY` and `HTTPS_PROXY` environment variables with the URL of your proxy server. Here's an example of how to set these variables:
362+
363+
```bash
364+
export HTTP_PROXY=http://proxy.example.com:8080
365+
export HTTPS_PROXY=http://proxy.example.com:8080
366+
```
367+
368+
- `proxy.example.com` is the domain or IP address of your proxy server.
369+
- `8080` is the port number of your proxy server.
370+
371+
#### Considerations
372+
- **Protocol:** Make sure to include the protocol (`http` or `https`) in the proxy URL.
373+
- **Authentication:** If your proxy requires authentication, you can include the username and password in the URL. For example: `http://username:[email protected]:8080`.
374+
375+
After setting the environment variables, the `ably-go` SDK will route its traffic through the specified proxy for both Rest and Realtime clients.
376+
377+
For more details on environment variable configurations in Go, you can refer to the [official Go documentation on http.ProxyFromEnvironment](https://golang.org/pkg/net/http/#ProxyFromEnvironment).
378+
379+
### Setting Up Proxy via custom http client
380+
381+
For Rest client, you can also set proxy by providing custom http client option `ably.WithHTTPClient`:
382+
383+
```go
384+
ably.WithHTTPClient(&http.Client{
385+
Transport: &http.Transport{
386+
Proxy: proxy // custom proxy implementation
387+
},
388+
})
389+
```
390+
391+
**Important Note** - Connection reliability is totally dependent on health of proxy server and ably will not be responsible for errors introduced by proxy server.
392+
356393
## Note on usage of ablytest package
357394
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.
358395
It can lead to unexpected behaviour, since some beta features may be deployed on the `sandbox` environment so that they can be tested before going into production.

0 commit comments

Comments
 (0)