diff --git a/net/portmapper/portmapper.go b/net/portmapper/portmapper.go index 9368d1c4e..3cdfb76ed 100644 --- a/net/portmapper/portmapper.go +++ b/net/portmapper/portmapper.go @@ -395,7 +395,9 @@ func (c *Client) listenPacket(ctx context.Context, network, addr string) (nettyp func (c *Client) invalidateMappingsLocked(releaseOld bool) { if c.mapping != nil { if releaseOld { - c.mapping.Release(context.Background()) + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + c.mapping.Release(ctx) } c.mapping = nil }