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

how to create a client connection to unix domain socket? #1195

Open
sprappcom opened this issue Sep 16, 2024 · 2 comments
Open

how to create a client connection to unix domain socket? #1195

sprappcom opened this issue Sep 16, 2024 · 2 comments

Comments

@sprappcom
Copy link

sprappcom commented Sep 16, 2024

Describe the Question
want to have a hertz golang client to unix domain socket calling.

Reproducible Code

something like... ?
client.WithNetwork("unix"), // <- here doesnt work like this. my backendAddr is "unix:///home/ubuntu/web.sock"

    newPool = &sync.Pool{
            New: func() interface{} {
                    cli, err := client.NewClient(
                            client.WithDialTimeout(1*time.Second),
                            client.WithMaxConnsPerHost(10240),
                            client.WithMaxIdleConnDuration(30*time.Second),
                            client.WithMaxConnDuration(0),
                            client.WithMaxConnWaitTimeout(10*time.Second),
                            client.WithKeepAlive(true),
                            client.WithNetwork("unix"), // <- here doesnt work like this. my backendAddr is "unix:///home/ubuntu/web.sock"
                            client.WithClientReadTimeout(60*time.Second),
                            client.WithWriteTimeout(60*time.Second),
                            client.WithDialer(standard.NewDialer()),
                            client.WithTLSConfig(&tls.Config{InsecureSkipVerify: true}),
                            client.WithHostClientConfigHook(func(hc interface{}) error {
                                    if hct, ok := hc.(*http1.HostClient); ok {
                                            hct.Addr = backendAddr
                                    }
                                    return nil
                            }),
                    )
                    if err != nil {
                            log.Fatalf("failed to create client for %s: %v", backendAddr, err)
                    }
                    return cli
            },
    }

Expected behavior

client unix domain socket backend calling to unix domain socket connection

Screenshots

Hertz version:

0.9.3

Environment:

go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE='*'
GOMODCACHE='/root/go/pkg/mod'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.1'
GODEBUG=''

Additional context
there's no information regarding this in doc.
previously mentioned here:
#1194

@sprappcom
Copy link
Author

@li-jin-gou @Duslia any help?

@FGYFFFF
Copy link
Contributor

FGYFFFF commented Sep 25, 2024

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

No branches or pull requests

2 participants