ionorg / ion-sfu

Pure Go WebRTC SFU
MIT License
962 stars 238 forks source link

panic: runtime error: index out of range [1] with length 0 #451

Closed nkonev closed 3 years ago

nkonev commented 3 years ago

Your environment.

router:

Limit the remb bandwidth in kbps

zero means no limits

maxbandwidth: 1500

max buffer time by ms for video tracks

maxbuffertime: 1000

Sets the audio level volume threshold.

Values from [0-127] where 0 is the loudest.

Audio levels are read from rtp extension header according to:

https://tools.ietf.org/html/rfc6464

audiolevelthreshold: 40

Sets the interval in which the SFU will check the audio level

in [ms]. If the active speaker has changed, the sfu will

emit an event to clients.

audiolevelinterval: 1000

Sets minimum percentage of events required to fire an audio level

according to the expected events from the audiolevelinterval,

calculated as audiolevelinterval/packetization time (20ms for 8kHz)

Values from [0-100]

audiolevelfilter: 20

simulcast:

Prefer best quality initially

bestqualityfirst: true

EXPERIMENTAL enable temporal layer change is currently an experimental feature,

enable only for testing.

enabletemporallayer: false

webrtc:

Range of ports that ion accepts WebRTC traffic on

Format: [min, max] and max - min >= 100

portrange: [5000, 5100]

if sfu behind nat, set iceserver

iceserver:

sdp semantics:

"unified-plan"

"plan-b"

"unified-plan-with-fallback"

sdpsemantics: "unified-plan"

toggle multicast dns support: https://tools.ietf.org/html/draft-mdns-ice-candidates-00

mdns: true

candidates:

In case you're deploying ion-sfu on a server which is configured with

a 1:1 NAT (e.g., Amazon EC2), you might want to also specify the public

address of the machine using the setting below. This will result in

all host candidates (which normally have a private IP address) to

be rewritten with the public address provided in the settings. As

such, use the option with caution and only if you know what you're doing.

Multiple public IP addresses can be specified as a comma separated list

if the sfu is deployed in a DMZ between two 1-1 NAT for internal and

external users.

nat1to1: ["x.y.z.*"]

icelite: true

turn:

Enables embeded turn server

enabled: true

Sets the realm for turn server

realm: "ion"

The address the TURN server will listen on.

address: "0.0.0.0:3478"

Certs path to config tls/dtls

cert="path/to/cert.pem"

key="path/to/key.pem"

portrange: [5200, 5300] auth:

Use an auth secret to generate long-term credentials defined in RFC5389-10.2

NOTE: This takes precedence over credentials if defined.

secret: "secretAwsome"

Sets the credentials pairs

credentials: "userN=passW"

log: level: "trace"

chat: url: base: "http://chat:1235" access: "/internal/access" notify: "/internal/video/notify"

Rest client

http: maxIdleConns: 2 idleConnTimeout: '10s' disableCompression: false

frontend: iceserver:


stacktrace

myhost chat-video[4803]: [2021-03-02 19:57:39.289] [INFO] [143][main.go][main] => --- Starting SFU Node --- myhost chat-video[4803]: [2021-03-02 19:57:39.293] [INFO] [178][main.go][main] => Listening at http://[:7000] myhost chat-video[4803]: [2021-03-02 19:57:39.295] [INFO] [114][main.go][startMetrics] => Metrics Listening at :8100 myhost chat-video[4803]: [2021-03-02 20:00:37.964] [INFO] [198][handler.go][addPeerToMap] => Storing peer for userId=3 to chatId=23 myhost chat-video[4803]: [2021-03-02 20:00:38.019] [INFO] [147][peer.go][Join] => peer cklsfrers000001179ladu0yz join session chat23 myhost chat-video[4803]: [2021-03-02 20:00:38.019] [INFO] [160][peer.go][Answer] => peer cklsfrers000001179ladu0yz got offer myhost chat-video[4803]: [2021-03-02 20:00:38.022] [DEBUG] [63][publisher.go][func3] => ice connection state: checking myhost chat-video[4803]: [2021-03-02 20:00:38.027] [DEBUG] [128][peer.go][func3] => on publisher ice candidate called for peer cklsfrers000001179ladu0yz myhost chat-video[4803]: [2021-03-02 20:00:38.028] [DEBUG] [128][peer.go][func3] => on publisher ice candidate called for peer cklsfrers000001179ladu0yz myhost chat-video[4803]: [2021-03-02 20:00:38.023] [INFO] [171][peer.go][Answer] => peer cklsfrers000001179ladu0yz send answer myhost chat-video[4803]: [2021-03-02 20:00:38.034] [INFO] [204][peer.go][Trickle] => peer cklsfrers000001179ladu0yz trickle myhost chat-video[4803]: [2021-03-02 20:00:38.036] [INFO] [204][peer.go][Trickle] => peer cklsfrers000001179ladu0yz trickle myhost chat-video[4803]: [2021-03-02 20:00:38.147] [DEBUG] [63][publisher.go][func3] => ice connection state: connected myhost chat-video[4803]: [2021-03-02 20:00:38.270] [DEBUG] [101][peer.go][func1] => peer cklsfrers000001179ladu0yz negotiation needed myhost chat-video[4803]: [2021-03-02 20:00:38.272] [INFO] [110][peer.go][func1] => peer cklsfrers000001179ladu0yz send offer myhost chat-video[4803]: [2021-03-02 20:00:38.273] [DEBUG] [116][peer.go][func2] => on subscriber ice candidate called for peer cklsfrers000001179ladu0yz myhost chat-video[4803]: [2021-03-02 20:00:38.274] [DEBUG] [116][peer.go][func2] => on subscriber ice candidate called for peer cklsfrers000001179ladu0yz myhost chat-video[4803]: [2021-03-02 20:00:38.290] [INFO] [184][peer.go][SetRemoteDescription] => peer cklsfrers000001179ladu0yz got answer myhost chat-video[4803]: [2021-03-02 20:00:38.290] [DEBUG] [57][subscriber.go][func1] => ice connection state: checking myhost chat-video[4803]: [2021-03-02 20:00:38.291] [INFO] [204][peer.go][Trickle] => peer cklsfrers000001179ladu0yz trickle myhost chat-video[4803]: [2021-03-02 20:00:38.310] [INFO] [204][peer.go][Trickle] => peer cklsfrers000001179ladu0yz trickle myhost chat-video[4803]: [2021-03-02 20:00:39.372] [DEBUG] [57][subscriber.go][func1] => ice connection state: connected myhost chat-video[4803]: [2021-03-02 20:00:39.828] [INFO] [160][peer.go][Answer] => peer cklsfrers000001179ladu0yz got offer myhost chat-video[4803]: [2021-03-02 20:00:39.830] [INFO] [171][peer.go][Answer] => peer cklsfrers000001179ladu0yz send answer myhost chat-video[4803]: [2021-03-02 20:00:39.832] [INFO] [204][peer.go][Trickle] => peer cklsfrers000001179ladu0yz trickle myhost chat-video[4803]: [2021-03-02 20:00:39.833] [INFO] [204][peer.go][Trickle] => peer cklsfrers000001179ladu0yz trickle myhost chat-video[4803]: [2021-03-02 20:00:39.842] [INFO] [204][peer.go][Trickle] => peer cklsfrers000001179ladu0yz trickle myhost chat-video[4803]: [2021-03-02 20:00:39.842] [INFO] [204][peer.go][Trickle] => peer cklsfrers000001179ladu0yz trickle myhost chat-video[4803]: [2021-03-02 20:00:40.136] [DEBUG] [48][publisher.go][func1] => Peer cklsfrers000001179ladu0yz got remote track id: 4965592e-c32a-4864-a654-4857956911d5 mediaSSRC: 739820034 rid : streamID: e5d85e22-b6e2-4998-85ea-d763ef5b0af7 myhost chat-video[4803]: [2021-03-02 20:00:40.136] [DEBUG] [180][router.go][AddReceiver] => NewBuffer BufferOptions={1500} myhost chat-video[4803]: [2021-03-02 20:00:41.670] [DEBUG] [48][publisher.go][func1] => Peer cklsfrers000001179ladu0yz got remote track id: 61acfdb8-e462-4216-ab6a-4911242f80e1 mediaSSRC: 3883774611 rid : streamID: e5d85e22-b6e2-4998-85ea-d763ef5b0af7 myhost chat-video[4803]: [2021-03-02 20:00:41.670] [DEBUG] [180][router.go][AddReceiver] => Setting feedback goog-remb myhost chat-video[4803]: [2021-03-02 20:00:41.670] [DEBUG] [180][router.go][AddReceiver] => Setting feedback transport-cc myhost chat-video[4803]: [2021-03-02 20:00:41.670] [DEBUG] [180][router.go][AddReceiver] => Setting feedback nack myhost chat-video[4803]: [2021-03-02 20:00:41.670] [DEBUG] [180][router.go][AddReceiver] => Setting feedback nack myhost chat-video[4803]: panic: runtime error: index out of range [1] with length 0 myhost chat-video[4803]: myhost chat-video[4803]: goroutine 200 [running]: myhost chat-video[4803]: encoding/binary.bigEndian.PutUint16(...) myhost chat-video[4803]: encoding/binary/binary.go:106 myhost chat-video[4803]: github.com/pion/ion-sfu/pkg/buffer.(Bucket).push(...) myhost chat-video[4803]: github.com/pion/ion-sfu@v1.9.2-0.20210302184455-3156f57c6cba/pkg/buffer/bucket.go:59 myhost chat-video[4803]: github.com/pion/ion-sfu/pkg/buffer.(Bucket).AddPacket(0xc00044aab0, 0xc000116900, 0x471, 0x471, 0x11297, 0x0, 0xd4c8e0, 0xc00000e018, 0x0, 0xc7956d) myhost chat-video[4803]: github.com/pion/ion-sfu@v1.9.2-0.20210302184455-3156f57c6cba/pkg/buffer/bucket.go:37 +0x279 myhost chat-video[4803]: github.com/pion/ion-sfu/pkg/buffer.(Buffer).calc(0xc000301e00, 0xc000116900, 0x471, 0x471, 0x16689ef507d9cdb9) myhost chat-video[4803]: github.com/pion/ion-sfu@v1.9.2-0.20210302184455-3156f57c6cba/pkg/buffer/buffer.go:304 +0x1e5 myhost chat-video[4803]: github.com/pion/ion-sfu/pkg/buffer.(Buffer).Bind(0xc000301e00, 0xc000432de0, 0x3, 0x4, 0xc00033af60, 0x1, 0x1, 0x5dc) myhost chat-video[4803]: github.com/pion/ion-sfu@v1.9.2-0.20210302184455-3156f57c6cba/pkg/buffer/buffer.go:169 +0x287 myhost chat-video[4803]: github.com/pion/ion-sfu/pkg/sfu.(router).AddReceiver(0xc000227e00, 0xc00033b0e0, 0xc000235e60, 0x0, 0x0, 0xc0002cad00) myhost chat-video[4803]: github.com/pion/ion-sfu@v1.9.2-0.20210302184455-3156f57c6cba/pkg/sfu/router.go:180 +0x4ad myhost chat-video[4803]: github.com/pion/ion-sfu/pkg/sfu.NewPublisher.func1(0xc000235e60, 0xc00033b0e0) myhost chat-video[4803]: github.com/pion/ion-sfu@v1.9.2-0.20210302184455-3156f57c6cba/pkg/sfu/publisher.go:49 +0x23b myhost chat-video[4803]: created by github.com/pion/webrtc/v3.(PeerConnection).onTrack myhost chat-video[4803]: github.com/pion/webrtc/v3@v3.0.10/peerconnection.go:451 +0x10f



It worked correctly on my forked repository on commit github.com/nkonev/ion-sfu v1.9.1-0.20210226202827-62c8b234441f

It seems root cause this one https://github.com/pion/ion-sfu/pull/449/files#diff-193890e385023f88670a054946ba694a057953837760a07fa9c4863ce35e436aR59

### What did you do?
I open js client then establish webrtc connection. I tested with Safari 14.0 (15610.1.28.1.9, 15610), Chrome 88.0.4324.192

### What did you expect?
Not to see this error

### What happened?
Panic
nkonev commented 3 years ago

Sorry, It is duplicate of https://github.com/pion/ion-sfu/issues/450