#2121·webrtc

Cannot add a candidate without specifying either sdpMid or sdpMLineIndex - Webrtc Wasm

Author: dcam0050Created Feb 10, 2022Updated Jun 20, 2026

Your environment.

  • Version: Ubuntu 21.10 (Offer) Ubuntu 20.04 (Answer) go 1.16 GOOS=wasm GOARCH=js pion v3.1.23

  • Browser (Offer) Google Chrome - Ubuntu 21.10 - Version 97.0.4692.99 (Official Build) (64-bit) Firefox - Ubuntu 21.10 - 97.0 (64-bit)

  • Other Information - stacktraces, related issues, suggestions how to fix, links for us to have context

What did you do?

I modified the pion to pion example in order to run the answer on a pc while running the offer inside of wasm. Candidate exchange follows trickle-ice for handling ice candidates as they arrive

What did you expect?

Expected a connection to be made and data transmission to start.

What happened?

Received this error in Firefox:

Uncaught (in promise) TypeError: Cannot add a candidate without specifying either sdpMid or sdpMLineIndex
    valueCall http://localhost:9090/wasm_exec.js:399
    _resume http://localhost:9090/wasm_exec.js:588
    _makeFuncWrapper http://localhost:9090/wasm_exec.js:599
    valueCall http://localhost:9090/wasm_exec.js:399
    _resume http://localhost:9090/wasm_exec.js:588
    _makeFuncWrapper http://localhost:9090/wasm_exec.js:599

And this error in google chrome:

wasm_exec.js:399 Uncaught (in promise) TypeError: Failed to execute 'addIceCandidate' on 'RTCPeerConnection': Candidate missing values for both sdpMid and sdpMLineIndex
    at syscall/js.valueCall (wasm_exec.js:399:31)
    at syscall_js.valueCall (main.wasm:0x180ab9)
    at syscall_js.Value.Call (main.wasm:0x17de8f)
    at github.com_pion_webrtc_v3.__PeerConnection_.AddICECandidate (main.wasm:0x9413b6)
    at wasm_pc_f_loop (main.wasm:0xe8903)
    at wasm_export_resume (main.wasm:0xe88e4)
    at global.Go._resume (wasm_exec.js:588:23)

When running both offer and answer on the same computer a data connection is created and data is sent but if the answer lies on a different computer over the internet, a connection is not established.