AdapterJS
AdapterJS copied to clipboard
'icecandidate' event not firing in IE 11
I'm submitting a...
[x] Bug report
Current behavior
In Internet Explorer, when attaching event listener to icecandidate event or setting onicecandidate property directly, event is not firing. In Chrome it works perfectly.
Expected behavior
icecandidate event fires in IE 11
Code
import { webRTCReady, addEvent } from 'adapterjs'
function initWebRTC(): Promise<boolean> {
return new Promise(resolve => {
webRTCReady((isPluginReady: boolean) => resolve(isPluginReady))
})
}
function getURL(): Promise<string> {
return new Promise<string>(resolve => {
const ConnectionCtor = (
window.RTCPeerConnection ||
(<any>window).mozRTCPeerConnection ||
(<any>window).webkitRTCPeerConnection
)
const connection = new ConnectionCtor({
iceServers: []
})
const noop = function () { }
const ipRegex = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/
connection.createDataChannel('')
connection.createOffer(
connection.setLocalDescription.bind(connection),
noop
)
function gotIceCandidate(ice) {
if (!ice || !ice.candidate || !ice.candidate.candidate) {
return
}
const ip = ipRegex.exec(ice.candidate.candidate)[1]
resolve(`ws://${ip}:8888`)
connection.onicecandidate = noop
}
// connection.onicecandidate = gotIceCandidate
addEvent(connection, 'icecandidate', gotIceCandidate)
})
}
await initWebRTC()
const url = await getURL()
// ...
Environment
AdapterJS version: 0.15.0
Browser:
- IE version 11
For Tooling issues:
- Node version: 8.4.0
- Typescript version: 2.5.3
- Platform: Windows 8.1
Hi, you have a working example here : https://plugin.temasys.io/demo/src/content/peerconnection/pc1/ Your code looks fine to me. Can you try setting the event listener before calling createOffer ? There is a chance the candidates are thrown before you have time to set the listener.