Here I am trying to POST 20 docs to my webservice using gorequest, but it creates 20 different TCP connection.
How can I make sure it use only one TCP connection instead of 20 or reuse the same connection.
Snippets:
request := gorequest.New()
for i := 1; i <= 20; i++ {
jsonH := `{"hostname": "node1"}`
req := request.Post(url).
Set("Content-Type", "application/json").
Set("Authorization", fmt.Sprintf("Bearer %s", RWToken)).
Send(jsonH)
resp, _, _ := req.End()
fmt.Printf("%T", req)
logs.Info(resp.StatusCode)
}
When i do netstat -an | grep 8181
tcp 0 0 192.168.0.1:8181 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.1:8181 192.168.0.1:60929 TIME_WAIT
tcp 0 0 192.168.0.1:8181 192.168.0.1:60928 TIME_WAIT
tcp 0 0 192.168.0.1:8181 192.168.0.1:60945 TIME_WAIT
tcp 0 0 192.168.0.1:8181 192.168.0.1:60944 TIME_WAIT
tcp 0 0 192.168.0.1:60927 192.168.0.1:8181 TIME_WAIT
tcp 0 0 192.168.0.1:8181 192.168.0.1:60946 TIME_WAIT
tcp 0 0 192.168.0.1:8181 192.168.0.1:60943 TIME_WAIT
tcp 0 0 192.168.0.1:8181 192.168.0.1:60947 TIME_WAIT
tcp 0 0 192.168.0.1:8181 192.168.0.1:60934 TIME_WAIT
tcp 0 0 192.168.0.1:8181 192.168.0.1:60936 TIME_WAIT
tcp 0 0 192.168.0.1:8181 192.168.0.1:60935 TIME_WAIT
tcp 0 0 192.168.0.1:8181 192.168.0.1:60940 TIME_WAIT
tcp 0 0 192.168.0.1:8181 192.168.0.1:60932 TIME_WAIT
tcp 0 0 192.168.0.1:8181 192.168.0.1:60939 TIME_WAIT
tcp 0 0 192.168.0.1:8181 192.168.0.1:60941 TIME_WAIT
tcp 0 0 192.168.0.1:8181 192.168.0.1:60930 TIME_WAIT
tcp 0 0 192.168.0.1:8181 192.168.0.1:60937 TIME_WAIT
tcp 0 0 192.168.0.1:8181 192.168.0.1:60933 TIME_WAIT
tcp 0 0 192.168.0.1:8181 192.168.0.1:60938 TIME_WAIT
tcp 0 0 192.168.0.1:8181 192.168.0.1:60931 TIME_WAIT
tcp 0 0 192.168.0.1:8181 192.168.0.1:60942 TIME_WAIT