openfresh / gosrt

Go SRT library with the net package like API.
MIT License
66 stars 16 forks source link

srt.Dialer hangs, but other side receives connection. #16

Open gissleh opened 3 years ago

gissleh commented 3 years ago

I'm using this library with libsrt 1.4.0, and listening works great, but dialing hangs when connecting to srt-live-transmit (tried both 1.4.0 and 1.4.2). The other side reports that the SRT source has connected, but dial will still time out.

The dialing part of the readme example also fails.

Is it caused by an incompatibility with libsrt 1.4, or is there an option with a bad default value?

xmedia-systems commented 3 years ago

I'm facing the same issue, reproducible with the following test which deadlocks forever:

func TestDial(t *testing.T) {
    wg := sync.WaitGroup{}
    wg.Add(1)
    go func() {
        l, _ := srt.Listen("srt", ":5001")
        sc, _ := l.Accept()
        b := make([]byte, 1316)
        var err error
        for err == nil {
            _, err = sc.Read(b)
        }
        wg.Done()
        sc.Close()
        l.Close()
    }()
    wg.Add(1)
    go func() {
        tc, _ := srt.Dial("srt", "127.0.0.1:5001")
        b := make([]byte, 1316)
        tc.Write(b)
        tc.Close()
        wg.Done()
    }()
    wg.Wait()

}

seems like connect expects some data to be received immediately: https://github.com/openfresh/gosrt/blob/master/srt/fd_strapi.go#L121