Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: cannot send UDP packet in windows 11 #52883

Closed
Ovi3 opened this issue May 13, 2022 · 4 comments
Closed

net: cannot send UDP packet in windows 11 #52883

Ovi3 opened this issue May 13, 2022 · 4 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@Ovi3
Copy link

Ovi3 commented May 13, 2022

What version of Go are you using (go version)?

$ go version
go version go1.17.7 windows/amd64

Does this issue reproduce with the latest release?

Not try

(I only reproduce this issue on my company client. Cannot bother him for more info)

What operating system and processor architecture are you using (winver)?

winver Output
$ winver
Windows OS 11 Version 21H2 (Build 22000.613)

What did you do?

package main

import (
	"net"
)

func main() {
	conn,err := net.DialUDP("udp",nil, &net.UDPAddr{
		IP: net.IPv4(8,8,8,8),
		Port: 9090,
	})

	if err != nil {
		panic(err)
	}

	_,err = conn.Write([]byte("udp test"))
	if err != nil {
		panic(err)
	}

	conn.Close()
}

open wireshark and run this code, there is no udp packet to 8.8.8.8:9090, and no panic error

but when I add code that reading from udp connection. It work:

package main

import (
	"net"
	"time"
)

func main() {
	conn,err := net.DialUDP("udp",nil, &net.UDPAddr{
		IP: net.IPv4(8,8,8,8),
		Port: 9090,
	})

	if err != nil {
		panic(err)
	}

	_,err = conn.Write([]byte("udp test"))
	if err != nil {
		panic(err)
	}

	conn.SetReadDeadline(time.Now().Add(1 * time.Second))
	buf := make([]byte,1024)
	_, _, _ = conn.ReadFromUDP(buf)

	conn.Close()
}

I also use Python, It work too:

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.sendto(b"test", ('8.8.8.8', 9090))

So I think maybe it's not windows 11 problem.

@heschi
Copy link
Contributor

heschi commented May 13, 2022

cc @ianlancetaylor @neild

@heschi heschi added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 13, 2022
@heschi heschi added this to the Backlog milestone May 13, 2022
@neild
Copy link
Contributor

neild commented May 13, 2022

Is is possible the packet is making it into a send buffer that isn't flushed when the program exits?

What happens if you insert a select{} after the write (causing the program to block indefinitely without exiting) instead of reading from the conn?

@Ovi3
Copy link
Author

Ovi3 commented May 20, 2022

I add select{} after the write (or add time.Sleep(3 * time.Second)) , It works.

package main

import (
	"net"
)

func main() {
	conn,err := net.DialUDP("udp",nil, &net.UDPAddr{
		IP: net.IPv4(8,8,8,8),
		Port: 9090,
	})

	if err != nil {
		panic(err)
	}

	_,err = conn.Write([]byte("udp test"))
	if err != nil {
		panic(err)
	}

        select{}

	conn.Close()
}

@seankhliao
Copy link
Member

Closing as this seems to be working

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jul 29, 2022
@golang golang locked and limited conversation to collaborators Jul 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants