vector: TCP source: "Socket not connected"

When using the socket source with type TCP and creating short-lived connections, vector quickly crashes with the following error:

source{name=in type=socket}: vector::sources::util::tcp: failed to accept socket error=Could not get peer address: Socket not connected (os error 107)

I narrowed the configuration down to the following:

[sources.in]
  address = "0.0.0.0:5514"
  mode = "tcp"
  type = "socket"

[sinks.blackhole]
  type = "blackhole"
  inputs = ["in"]
  print_amount = 1000

I run it as a docker image like so: docker run -it --network host -v $(pwd):/etc/vector/config timberio/vector:nightly-alpine --config /etc/vector/config/config.toml

And then I send something via netcat, directly closing the connection afterwards. Sometimes it takes a couple attempts, but it does consistently crash at some point. You should definitely be able to reproduce it with something like: while true; do echo "hi" | nc -c -v localhost 5514; done

When I connect to it without the -c flag (i.e. keeping the connection open), everything is fine. The error appears to only happen when the connection is closed directly after sending.

Log level trace doesn’t reveal any more information, btw.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (15 by maintainers)

Most upvoted comments

By the way: I’m happy to jump on a call if need be and you’d like to see/debug this hands-on. (We might have a bit of a timezone issue but we could probably figure something out) 😃

Hmm, still can’t reproduce, and I’ve tried with GNU netcat, OpenBSD netcat, and tcpclient from ucspi-tcp, and Vector in both debug and release mode. @Hoverbear also tried. I do believe this is a real problem that we should resolve, it’s just frustrating we can’t produce a test case that can demonstrate the problem so we can know we’ve fixed it. Since you indicate you can build from source, I will write a patch for what I think is the problem and see if that resolves the issue for you.