gliderlabs/logspout

can not dial go server locally

KePeng1019 opened this issue · 4 comments

i run a udp server and i can dial my udp server locally.

func main() {
	addr := net.UDPAddr{
		IP:   net.IP{0, 0, 0, 0},
		Port: 5869,
	}

	conn, err := net.ListenUDP("udp4", &addr)
	if err != nil {
		fmt.Println(err)
		return
	}
	defer conn.Close()

	for {
		handleData(conn)
	}
}

func handleData(conn *net.UDPConn) {
	var buf [1024]byte

	n, _, err := conn.ReadFromUDP(buf[0:])

	if err != nil {
		log.Println(err)
		return
	}

	msg := string(buf[0:n])

	fmt.Println(msg)
}

but when i run your images with command

docker run --name="logspout" \
       --network=host \
        --volume=/var/run/docker.sock:/var/run/docker.sock \
        gliderlabs/logspout \
        syslog://0.0.0.0:5869

i got connection refused err:

# logspout v3.2.6 by gliderlabs
# adapters: multiline tcp udp tls raw syslog
# options : persist:/mnt/routes
# jobs    : pump routes http[health,logs,routes]:80
# routes  :
#   ADAPTER	ADDRESS		CONTAINERS	SOURCES	OPTIONS
#   syslog	0.0.0.0:5869				map[]
2019/12/12 12:45:37 syslog: write udp 127.0.0.1:41165->127.0.0.1:5869: write: connection refused
2019/12/12 12:45:37 syslog: write udp 127.0.0.1:41165->127.0.0.1:5869: write: connection refused
2019/12/12 12:45:37 syslog: write udp 127.0.0.1:41165->127.0.0.1:5869: write: connection refused
2019/12/12 12:45:37 syslog: write udp 127.0.0.1:41165->127.0.0.1:5869: write: connection refused
2019/12/12 12:45:37 syslog: write udp 127.0.0.1:41165->127.0.0.1:5869: write: connection refused
2019/12/12 12:45:37 syslog: write udp 127.0.0.1:41165->127.0.0.1:5869: write: connection refused

it did not work even i run a tcp server and use syslog+tcp command to run, please help.

does it work if you replace the 0.0.0.0 in syslog://0.0.0.0:5869 with the address of the container running the udp server?

does it work if you replace the 0.0.0.0 in syslog://0.0.0.0:5869 with the address of the container running the udp server?
I run my udp server in container and get it address, i got the same err as below

docker run --name="logspout" \
       --network=host \
        --volume=/var/run/docker.sock:/var/run/docker.sock \
        gliderlabs/logspout \
        syslog://172.17.0.2:5689
# logspout v3.2.6 by gliderlabs
# adapters: raw syslog multiline tcp udp tls
# options : persist:/mnt/routes
# jobs    : pump routes http[health,logs,routes]:80
# routes  :
#   ADAPTER	ADDRESS		CONTAINERS	SOURCES	OPTIONS
#   syslog	172.17.0.2:5689				map[]
2019/12/13 02:28:55 syslog: write udp 172.17.0.1:54098->172.17.0.2:5689: write: connection refused
2019/12/13 02:28:55 syslog: write udp 172.17.0.1:54098->172.17.0.2:5689: write: connection refused
2019/12/13 02:28:55 syslog: write udp 172.17.0.1:54098->172.17.0.2:5689: write: connection refused
2019/12/13 02:28:55 syslog: write udp 172.17.0.1:54098->172.17.0.2:5689: write: connection refused
2019/12/13 02:28:55 syslog: write udp 172.17.0.1:54098->172.17.0.2:5689: write: connection refused
2019/12/13 02:28:55 syslog: write udp 172.17.0.1:54098->172.17.0.2:5689: write: connection refused

172.17.0.2 is ip address i got from my container ifconfig command.

How are you running the udp server?

it works when i run udp server in docker, thanks