Skip to content

aternos and other servers that don't respond to raknet pings don't work #346

@HashimTheArab

Description

@HashimTheArab

If the server doesn't respond to raknet pings this will block forever until the context times out.
It should be like this, pings usually respond in <1s

// Try pinging first with a short timeout so we don't block the dial
// if the server has pinging blocked.
pingCtx, pingCancel := context.WithTimeout(ctx, time.Second*3)
pong, err = n.PingContext(pingCtx, address)
pingCancel()
if err == nil {
	netConn, err = n.DialContext(ctx, addressWithPongPort(pong, address))
} else {
	netConn, err = n.DialContext(ctx, address)
}

var netConn net.Conn
if pong, err = n.PingContext(ctx, address); err == nil {
netConn, err = n.DialContext(ctx, addressWithPongPort(pong, address))
} else {
netConn, err = n.DialContext(ctx, address)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions