Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client options: allow Proxy #273

Open
matthew-ceravolo opened this issue Jan 24, 2025 · 1 comment
Open

client options: allow Proxy #273

matthew-ceravolo opened this issue Jan 24, 2025 · 1 comment

Comments

@matthew-ceravolo
Copy link

matthew-ceravolo commented Jan 24, 2025

Proposed changes

when instantiating a new live websocket client, allow setting Proxy for the websocket dialer that is created downstream. or allow providing the full websocket dialer struct directly. also allow modifying the preset headers (like Host)

Context

we are using Deepgram on-prem, and our system uses HTTP_PROXY, HTTPS_PROXY, and NO_PROXY, and the difference between our service working and not working is this line in the websocket.Dialer creation:

Proxy: http.ProxyFromEnvironment,

as well as the removal of: myHeader.Set("Host", c.cOptions.Host)

Possible Implementation

allow providing the exact Proxy value, providing the websocket dialer, or allow Proxy: true/false and have it set the Proxy line above when true. also somehow allow custom header creation/deletion?

Other information

I'm unable to reach my deepgram-on-prem instance without the proxy from environment setting and without removal of the Host header

@DamienDeepgram
Copy link
Contributor

You should be able to use the context to make such changes I think

// Go context with custom headers
headers := make(http.Header)
headers.Set("Authorization", "token YOUR_API_KEY")
headers.Set("User-Agent", "MyCustomUserAgent/1.0")
headers.Del("Host") // Remove the Host header

ctx := context.WithValue(context.Background(), interfaces.HeadersContext{}, headers)

// Set the Client options
cOptions := &interfaces.ClientOptions{}

// Create a new stream using the 
dgClient, err := speak.NewWSUsingChan(ctx, "", cOptions)
if err != nil {
	fmt.Println("ERROR creating TTS connection:", err)
	return
}

See: https://github.com/deepgram/deepgram-go-sdk/blob/main/pkg/client/speak/client.go#L188-L207

Sample code you could modify with the above change
https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/text-to-speech/websocket/simple_channel/main.go#L234-L252

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants