go-ping / ping

ICMP Ping library for Go
MIT License
1.31k stars 344 forks source link

Randomly running into issue while continously pinging 1.1.1.1 #207

Closed Technerder closed 1 year ago

Technerder commented 2 years ago

The following error is thrown seemingly at random:

2022/03/10 01:01:03 FATAL: sending packet: write ip4 0.0.0.0->1.1.1.1: wsasendto: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.
2022/03/10 08:43:03 An error occurred while trying to ping: read ip4 0.0.0.0: wsarecvfrom: A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself.
panic: An error occurred while trying to ping: read ip4 0.0.0.0: wsarecvfrom: A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself.

How can I fix this?

CHTJonas commented 2 years ago

I think this might be related to #168. Any more information you can share about your system - OS, Go version, code that reproduces the error etc.?

Technerder commented 2 years ago

The program is meant to be run for pretty much forever

OS: Windows 10 (10.0.19044 Build 19044) Go: go1.17.5 windows/amd64

pinger, err := ping.NewPinger("1.1.1.1")
if err != nil {
    log.Panicf("An error occurred while trying to create pinger: %v\n", err)
}
pinger.Timeout = 10
pinger.SetPrivileged(true)
pinger.OnRecv = func(pkt *ping.Packet) {
    // Logging code for the ping data
}
err = pinger.Run()
if err != nil {
    log.Panicf("An error occurred while trying to ping: %v\n", err)
}