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: UDPConn.WriteToUDP not sending anything on Windows #38202

Closed
jmarkel44 opened this issue Apr 1, 2020 · 23 comments
Closed

net: UDPConn.WriteToUDP not sending anything on Windows #38202

jmarkel44 opened this issue Apr 1, 2020 · 23 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows release-blocker WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@jmarkel44
Copy link

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

$ go version
go version go1.11.4 windows/amd64

Does this issue reproduce with the latest release?

N/A

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

go env Output
$ go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\jmarkel\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\repo
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\jmarkel\AppData\Local\Temp\go-build202622878=/tmp/go-build -gno-record-gcc-switches

What did you do?

Trying to run an mdns query using the hashicorp/mdns client

https://github.com/hashicorp/mdns

What did you expect to see?

Expected to see a list of devices with mDNS services.

What did you see instead?

No results.
Please see the attached call stack.

With Wireshark running, I was not seeing any packets when the program was invoked.
windows

It's as if the call into the dll (WSASentTo()) to send the UDP message is not working correctly, though no errors are thrown when stepping through the code.

@andybons
Copy link
Member

andybons commented Apr 1, 2020

Without code to reproduce this (ideally a minimal reproduction), it is extremely difficult to diagnose what is going on. Do you have an example client/server setup you could provide? Perhaps this would also be more appropriate for hashicorp/mdns#80 and once you’ve determined it’s an issue with the Go toolchain, you could then revisit this issue.

@andybons andybons changed the title WSASendTo() not working? net: UDPConn.WriteToUDP not sending anything on Windows Apr 1, 2020
@andybons andybons added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Apr 1, 2020
@andybons andybons added this to the Unplanned milestone Apr 1, 2020
@jmarkel44
Copy link
Author

package main

import (
        "fmt"
        "github.com/hashicorp/mdns"
)

func main() {
        // Make a channel for results and start listening
        fmt.Println("searching for new entries")
        entriesCh := make(chan *mdns.ServiceEntry, 4)
        go func() {
                for entry := range entriesCh {
                        fmt.Printf("Got new entry: %v\n", entry)
                }
        }()

        // Start the lookup
        mdns.Lookup("_ssh._tcp", entriesCh)
        close(entriesCh)
}

Please see the call stack for verification of the Golang toolchain.

@andybons
Copy link
Member

andybons commented Apr 1, 2020

Does this work as expected on platforms other than Windows?

@jmarkel44
Copy link
Author

yeah, works great on a Pi. see attachment.

pi_mdns

@andybons
Copy link
Member

andybons commented Apr 1, 2020

Thanks. That’s helpful.

Can you attach text instead of images, please? Images are harder to read and hurt accessibility.

@andybons andybons added OS-Windows and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Apr 1, 2020
@andybons
Copy link
Member

andybons commented Apr 1, 2020

@mikioh @alexbrainman

@jmarkel44
Copy link
Author

Sure. Will do.

@andybons
Copy link
Member

andybons commented Apr 1, 2020

Tentatively marking this a release blocker for 1.15 while we gather more info.

@andybons andybons modified the milestones: Unplanned, Go1.15 Apr 1, 2020
@andybons
Copy link
Member

andybons commented Apr 1, 2020

Could be due to one of the known bugs listed here: https://golang.org/pkg/net/#pkg-note-BUG

@jmarkel44
Copy link
Author

Just wanted to note I've updated Go (same problem, however)

go version go1.14.1 windows/amd64

@jmarkel44
Copy link
Author

Any updates on this or any potential workarounds?

@andybons
Copy link
Member

andybons commented Apr 3, 2020

@jmarkel44 it’s been two days. Please be patient.

@ianlancetaylor
Copy link
Contributor

I don't understand the test program, as it doesn't wait for the goroutine to complete. What happens if you use a sync.WaitGroup or some such thing to ensure that your program doesn't exit before the goroutine finishes running?

@jmarkel44
Copy link
Author

There's a Timeout in the Lookup function. The code above is the recommended way to use the library too, based on github.com/hashicorp/mdns.

As noted, this works perfectly on a RPi.

Thanks.

@ianlancetaylor
Copy link
Contributor

I'm sure you're right, but when I look at that program it looks clearly incorrect. Humor me. Thanks.

@jmarkel44
Copy link
Author

What results are you getting when running the program?

@ianlancetaylor
Copy link
Contributor

I don't have a Windows system.

@ianlancetaylor
Copy link
Contributor

But on my GNU/Linux system I get

searching for new entries
2020/04/03 13:09:02 [INFO] mdns: Closing client {0xc000010030 0xc000010038 0xc000010040 0xc000010048 1 0xc0000181e0}

@jmarkel44
Copy link
Author

so if you do something like

$ dns-sd -B _workstation._tcp

are there any mDNS devices on the network?

@ianlancetaylor
Copy link
Contributor

I don't have dns-sd installed.

It would not surprise me if there are no mDNS devices on the network.

@alexbrainman
Copy link
Member

@jmarkel44

I never used this package github.com/hashicorp/mdns - I don't know what it does. But I tried running your program on Linux:

searching for new entries
2020/04/05 16:52:10 [INFO] mdns: Closing client {0xc000010030 0xc000010038 0xc000010040 0xc000010048 true 0xc000068180 {1 0}}
2020/04/05 16:52:10 [ERR] mdns: Failed to read packet: read udp4 0.0.0.0:55783: use of closed network connection

and on Windows

searching for new entries
2020/04/05 16:54:47 [ERR] mdns: Failed to bind to udp6 port: listen udp6 [ff02::fb]:5353: setsockopt: not supported by windows
2020/04/05 16:54:48 [INFO] mdns: Closing client {0xc00014c020 0xc00014c028 0xc00014c030 <nil> true 0xc000108180 {1 0}}
2020/04/05 16:54:48 [ERR] mdns: Failed to read packet: read udp4 0.0.0.0:54096: use of closed network connection

And 2 outputs looks very similar to me.

If you think the problem is in UDPConn.WriteToUDP, please, create small program that we can run on our computers to investigate. Do not assume we have Wireshark installed or other special tools available.

Thank you.

Alex

@andybons andybons added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 5, 2020
@jmarkel44
Copy link
Author

So this came down to a set-interface issue on the windows platform. traversing the entire list of possible interfaces resolves the issue we were seeing with mdns package.

Thanks for the help!

Closing the ticket.

@arojoal
Copy link

arojoal commented May 24, 2020

So this came down to a set-interface issue on the windows platform. traversing the entire list of possible interfaces resolves the issue we were seeing with mdns package.

Thanks for the help!

Closing the ticket.

Please, could you provide a code example of the solution?

@golang golang locked and limited conversation to collaborators May 24, 2021
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. OS-Windows release-blocker WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

6 participants