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

Rejected SRT request keeps getting accepted #59

Closed
unext-wendong opened this issue Jun 21, 2024 · 1 comment · Fixed by #62
Closed

Rejected SRT request keeps getting accepted #59

unext-wendong opened this issue Jun 21, 2024 · 1 comment · Fixed by #62

Comments

@unext-wendong
Copy link

In the listener mode, it seems if the AcceptFunc returns REJECT, the same request will keep getting accepted, even though the incoming socket has gone.

The following sample code demonstrates the issue:

package main

import (
    "fmt"
    "time"

    srt "github.com/datarhei/gosrt"
)

func main() {
    conf := srt.DefaultConfig()
    ln, err := srt.Listen("srt", ":6000", conf)
    if err != nil {
        fmt.Println("err 1", err)
        return
    }

    for {
        fmt.Println("Accepting...")
        conn, mode, err := ln.Accept(func(req srt.ConnRequest) srt.ConnType {
            // check connection request
            fmt.Println("Got connection", req.RemoteAddr())
            time.Sleep(3 * time.Second)
            fmt.Println("Rejecting...")
            return srt.REJECT
        })
        if err != nil {
            fmt.Println("err 2", err)
            return
        }

        fmt.Println("conn", conn)
        if mode == srt.REJECT {
            // rejected connection, ignore
            continue
        }

        fmt.Println("mode", mode)
    }
}

Reproduce procedure:

  1. Start the listener.
  2. Use any SRT client to try to connect to the listener.
  3. Stop the SRT client once the listener starts accepting the request.
  4. Observe the listener behavior.

We observed the following output:

Accepting...
Got connection [::1]:65203
Rejecting...
conn <nil>
Accepting...
Got connection [::1]:65203
Rejecting...
conn <nil>
Accepting...
Got connection [::1]:65203
Rejecting...
conn <nil>
Accepting...
Got connection [::1]:65203
Rejecting...
conn <nil>
Accepting...
Got connection [::1]:65203
@unext-wendong
Copy link
Author

unext-wendong commented Jun 21, 2024

From what I can tell, it's like it has gone to an endless loop. <-- Not accurate

Sorry, I shouldn't say "endless", it seems to be between 4 to around 12 times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant