heimdall icon indicating copy to clipboard operation
heimdall copied to clipboard

Support single connection for multiple request

Open irnurzaman opened this issue 4 years ago • 3 comments

Is this library support using single connection for multiple request? So it doesn't need handshake process for every request

irnurzaman avatar Jan 23 '21 04:01 irnurzaman

you can use custom client:

type client struct {
	client *http.Client
	transport http.RoundTripper
}

func (client *client) Do(request *http.Request) (*http.Response, error) {
	request.Close = false //This will be prevent closing of tcp connection, heimdall sets this attribute on true
	return client.client.Do(request) \
} 

hystrix.NewClient(
		hystrix.WithHTTPTimeout(30*time.Second),
		hystrix.WithHTTPClient(NewClient()) 
	) 

lukas016 avatar Mar 18 '21 13:03 lukas016

@lukas016 do u know why we close tcp connection after every request instead of reusing it?

komalasurya avatar Dec 09 '21 10:12 komalasurya

@komalasurya sorry, but i don't use or follow this project anymore. So if my comment above do problem you/i can deleted it. In my use cases i don't need close each connection to server, but heimdall wasn't very well for my use cases and comment above is from one of tests, when it works for me.

lukas016 avatar Dec 09 '21 16:12 lukas016