hap icon indicating copy to clipboard operation
hap copied to clipboard

Build window fail

Open zuozhehao opened this issue 3 years ago • 4 comments

goroutine 18 [running]:
github.com/brutella/dnssd.(*Service).IPsAtInterface(0xc0000736b8, 0x0)
        D:/***/github.com/brutella/[email protected]/service.go:150 +0x3d
github.com/brutella/dnssd.A({{0xc000212020, 0x4}, {0x6d4654, 0x9}, {0x6d3039, 0x5}, {0xc000212024, 0xc}, 0xc000206120, 0x0, ...}, ...)
        D:/***/github.com/brutella/[email protected]/dns.go:116 +0x39
github.com/brutella/dnssd.containsConflictingAnswers(0xc000406090, 0xc000214020)
        D:/***/github.com/brutella/[email protected]/responder.go:465 +0xbb
github.com/brutella/dnssd.findConflicts(0xc000406090, {0xc00040a010, 0x1, 0x1?})
        D:/***/github.com/brutella/[email protected]/responder.go:446 +0x9b
github.com/brutella/dnssd.(*responder).handleRequest(0xc000210000, 0xc000406090)
        D:/***/github.com/brutella/[email protected]/responder.go:238 +0x195
github.com/brutella/dnssd.(*responder).respond(0xc000210000, {0x775710, 0xc00022c040})
        D:/***/github.com/brutella/[email protected]/responder.go:203 +0x1d4
github.com/brutella/dnssd.(*responder).Respond(0xc000210000, {0x775710, 0xc00022c040})
        D:/***/github.com/brutella/[email protected]/responder.go:113 +0x3ef
github.com/brutella/hap.(*Server).listenAndServe.func1()
        D:/***/github.com/brutella/[email protected]/server.go:205 +0x37
created by github.com/brutella/hap.(*Server).listenAndServe
        D:/***/github.com/brutella/[email protected]/server.go:204 +0x465

Process finished with the exit code 2

Same question https://github.com/brutella/hc/issues/201

zuozhehao avatar Mar 28 '22 07:03 zuozhehao

I'm still confused on why s.ifaceIPs is nil only on Windows? Doesn't make any sense!

brutella avatar Mar 28 '22 07:03 brutella

I'm still confused on why s.ifaceIPs is nil only on Windows? Doesn't make any sense!

I haven't added any code yet, just use the example code

package main

import (
	"github.com/brutella/hap"
	"github.com/brutella/hap/accessory"

	"context"
	"log"
	"os"
	"os/signal"
	"syscall"
)

func main() {
	// Create the switch accessory.
	a := accessory.NewSwitch(accessory.Info{
		Name: "Lamp",
	})

	// Store the data in the "./db" directory.
	fs := hap.NewFsStore("./db")

	// Create the hap server.
	server, err := hap.NewServer(fs, a.A)
	if err != nil {
		// stop if an error happens
		log.Panic(err)
	}

	// Setup a listener for interrupts and SIGTERM signals
	// to stop the server.
	c := make(chan os.Signal)
	signal.Notify(c, os.Interrupt)
	signal.Notify(c, syscall.SIGTERM)

	ctx, cancel := context.WithCancel(context.Background())
	go func() {
		<-c
		// Stop delivering signals.
		signal.Stop(c)
		// Cancel the context to stop the server.
		cancel() 
	}()

	// Run the server.
	server.ListenAndServe(ctx)
}

zuozhehao avatar Mar 28 '22 08:03 zuozhehao

I'm still confused on why s.ifaceIPs is nil only on Windows? Doesn't make any sense!

I haven't added any code yet, just use the example code

package main

import (
	"github.com/brutella/hap"
	"github.com/brutella/hap/accessory"

	"context"
	"log"
	"os"
	"os/signal"
	"syscall"
)

func main() {
	// Create the switch accessory.
	a := accessory.NewSwitch(accessory.Info{
		Name: "Lamp",
	})

	// Store the data in the "./db" directory.
	fs := hap.NewFsStore("./db")

	// Create the hap server.
	server, err := hap.NewServer(fs, a.A)
	if err != nil {
		// stop if an error happens
		log.Panic(err)
	}

	// Setup a listener for interrupts and SIGTERM signals
	// to stop the server.
	c := make(chan os.Signal)
	signal.Notify(c, os.Interrupt)
	signal.Notify(c, syscall.SIGTERM)

	ctx, cancel := context.WithCancel(context.Background())
	go func() {
		<-c
		// Stop delivering signals.
		signal.Stop(c)
		// Cancel the context to stop the server.
		cancel() 
	}()

	// Run the server.
	server.ListenAndServe(ctx)
}

@brutella @zuozhehao This might have something to do with IPv6.

hepeichun avatar May 06 '22 00:05 hepeichun

https://github.com/brutella/dnssd/blob/master/mdns.go#L146

image

I think it should be caused here.


https://github.com/brutella/dnssd/blob/master/mdns.go#L220

it's error message read udp4 0.0.0.0:5353: use of closed network connection

@brutella

zuozhehao avatar Jun 29 '22 06:06 zuozhehao