Skip to content

SCTP fails when using SetInterfaceFilter and pion is an answerer #3176

@iamoskvin

Description

@iamoskvin

Summary

I want to disable all host candidates and use only server-reflexive (srflx) ones.
To achieve that, I used SettingEngine.SetInterfaceFilter like this:

settingEngine.SetInterfaceFilter(func(name string) bool {
    return false
})

This works correctly when Pion is an offerer: the ICE connection establishes, and SCTP works as expected.

However, when Pion acts as an answerer, ICE succeeds but SCTP fails in ~80% of cases. The failure happens during SCTP handshake: the incoming COOKIE-ACK never arrives, even though ICE reports "connected".

In about 20% of runs, the full connection including SCTP does succeed — so the behavior is stochastic.

Investigation

Using strace, I observed that:

In normal operation, Pion creates two distinct UDP sockets (separate file descriptors).

When using SetInterfaceFilter (excluding all interfaces), both srflx and host candidates share the same underlying socket (same FD).

I suspect this causes an internal conflict or race condition when routing incoming packets (especially during SCTP setup), particularly for answerer mode.

Environment

Pion version: v4.0.10

Remote peer: Google Chrome 138.0.7204.49

OS: Linux (but should be reproducible cross-platform)

Repro

Use SetInterfaceFilter to exclude all interfaces.

Set up a peer connection where Pion is an answerer.

Wait for Chrome to initiate.

Observe that ICE connects but SCTP often fails.

Expected behavior

Even with a single srflx candidate and one UDP socket, SCTP should succeed reliably when Pion is an answerer.

Additional notes

I suspect a socket muxing issue in ICE or DTLS layers when both host and srflx candidates share a socket (fd).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions