FAQ
It looks like you aren't reading the response body before closing it. If you don't read the body, and simply close, then the connection will not be reused.

Try adding a `io.Copy(ioutil.Discard, resp.Body)` before your call to `resp.Body.Close()`.
On Aug 19, 2013, at 6:24 AM, Niko Schwarz wrote:

This page says that I have 16k ports to play with:

http://superuser.com/questions/145989/does-mac-os-x-throttle-the-rate-of-socket-creation

So, given that I never need more than 512 at any point in time -- what's
wrong? Why aren't they recycled properly?

Niko
On Monday, August 19, 2013 2:54:56 PM UTC+2, Nick Craig-Wood wrote:
On 19/08/13 13:38, Niko Schwarz wrote:
I've had a snippet of code that polls a local server very frequently,
and I'm somewhat surprised in how many ways it's failing. I've tried to
simplify it, and the following sadly isn't as diverse in its error
messages. [snip]
It produces three error messages on OSX:


panic: Get http://localhost:7000: dial tcp 127.0.0.1:7000:
connection reset by peer


panic: Get http://localhost:7000: lookup localhost: no such host


panic: Get http://localhost:7000: dial tcp 127.0.0.1:7000: too many
open files


The last of which actually makes sense, and can be avoided by `ulimit -n
10000`

The first might also make sense if I'm just overloading the server.
However, the server doesn't give any log output indicating this. The
middle one just seems nuts to me.
I suspect it is a consequence of running out of sockets. Quite likely a
name lookup needs a socket (don't know exactly how OS X works though!).


--
Nick Craig-Wood <ni...@craig-wood.com <javascript:>> --
http://www.craig-wood.com/nick
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 8 of 11 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedAug 19, '13 at 12:38p
activeAug 27, '13 at 10:10p
posts11
users6
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase