My server is running out of available sockets while I am using goroutines (limited to 100 concurrently) because once a goroutine finishes the ethclient.Client socket stays open in TIME_WAIT status for too long, instead of closing immediately after it has returned the required data, as is mentioned in this issue comment.

After about 30000 sockets are sitting in TIME_WAIT then my app fails. Sockets are closed faster on macOS 10.13 than on Ubuntu 14.04 it seems, as the problem is less common on a Mac.

The golang net package allows you to set SO_LINGER to 0 via setLinger but I don't see a similar option for ethclient.Client but maybe I am missing something


it's not an Ethereum question, but you can find the clue here:

[root@ethnode /root]# echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout
  • it's inside a docker container on GKE so I can't edit those system level values, I'd much prefer to shutdown the connection on the client side than trying to manage it on each server – xref Jul 17 '18 at 23:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.