http.Transport and too many connection problem.

53 views
Skip to first unread message

bronze man

unread,
Aug 25, 2016, 11:17:30 PM8/25/16
to golang-nuts
As I can see from the comment of http.Transport :

// Transports should be reused instead of created as needed.

The comment telled me that I need reuse the transports.

But i am writing a rpc system that the caller can pass different dialler to make http request.
It almost impossible for my rpc package implementer to reuse the transports object.
And the caller of my rpc package do not want to reuse the object either.

So the workaround to those complex stuff is to disable the keep alive in http.Transport by default(the caller can open it if them reuse the object).

So How can I simplify this reuse stuff?
If I disable keepAlive, can http.Transport be gc? 

* If I store the transports in an map, I can not know which dialler is same as another.
* I can set the IdleConnTimeout to 60*time.Second.But I looks useless if the callers just create new object again and again.
Reply all
Reply to author
Forward
0 new messages