Setsockopt: invalid argument in net/http.*Server.Serve

I’m getting very strange errors in https://github.com/romshark/zipapi I can’t reproduce locally on my macOS 10.14.6 (there the tests work just fine!):

set tcp 127.0.0.1:34121->127.0.0.1:48016: setsockopt: invalid argument

Tried both TravisCI and CircleCI but neither worked as you can see:
https://travis-ci.org/romshark/zipapi/jobs/581079397#L261
https://circleci.com/gh/romshark/zipapi/5

The error is returned by net/http.*Server.Serve right here: https://github.com/romshark/zipapi/blob/master/api/api.go#L105

All I did is I’ve implemented the keep-alive listener myself: https://github.com/romshark/zipapi/blob/master/api/tcpKeepAliveListener.go and made it take a free port automatically when none is given: https://github.com/romshark/zipapi/blob/master/api/api.go#L66.

Any idea what this error might be caused by?

EDIT:

I’ve commented out the following lines:

if err := tc.SetKeepAlive(true); err != nil {
	return nil, err
}
if err := tc.SetKeepAlivePeriod(ln.KeepAliveDuration); err != nil {
	return nil, err
}

And now the tests work on TravisCI too.

Now I’m wondering why this is happening?!

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.