Uncaught RTCError: Transport channel closed and app.js:73056 Uncaught Error: Connection failed. at makeError (app.js:73056) at Peer._onConnectionStateChange (app.js:73698) at RTCPeerConnection.Peer._pc.onconnectionstatechange (app.js:73160)
See original GitHub issuei create one video call application Laravel & ReactJS (based on WebRTC) , in this when i call to another member i get this error
app.js:8443 Uncaught RTCError: Transport channel closed
app.js:73056 Uncaught Error: Connection failed. at makeError (app.js:73056) at Peer._onConnectionStateChange (app.js:73698) at RTCPeerConnection.Peer._pc.onconnectionstatechange (app.js:73160)
here is my code
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import MediaHandler from '../MediaHandler'
import Pusher from "pusher-js";
import Peer from 'simple-peer';
const APP_KEY='347xxxxxxxxxaf756';
export default class App extends Component{
constructor() {
super();
this.state = {
hasMedia: false,
otherUserId: null
};
this.user = window.user;
this.user.stream = null;
this.peers = {};
this.mediaHandler = new MediaHandler();
this.setupPusher();
this.callTo = this.callTo.bind(this);
this.setupPusher = this.setupPusher.bind(this);
this.startPeer = this.startPeer.bind(this);
}
UNSAFE_componentWillMount(){
this.mediaHandler.getPermissions()
.then((stream) => {
this.setState({hasMedia: true});
this.user.stream = stream;
try {
this.myVideo.srcObject = stream;
} catch (e) {
this.myVideo.src = URL.createObjectURL(stream);
}
this.myVideo.play();
})
}
setupPusher() {
this.pusher = new Pusher(APP_KEY, {
authEndpoint: '/pusher/auth',
cluster: 'ap2',
auth: {
params: this.user.id,
headers: {
'X-CSRF-Token': window.csrfToken
}
}
});
this.channel = this.pusher.subscribe('presence-video-channel');
this.channel.bind(`client-signal-${this.user.id}`, (signal) => {
let peer = this.peers[signal.userId];
// if peer is not already exists, we got an incoming call
if(peer === undefined) {
this.setState({otherUserId: signal.userId});
peer = this.startPeer(signal.userId, false);
}
peer.signal(signal.data);
});
}
startPeer(userId, initiator = true) {
const peer = new Peer({
initiator,
stream: this.user.stream,
trickle: false
});
peer.on('signal', (data) => {
this.channel.trigger(`client-signal-${userId}`, {
type: 'signal',
userId: this.user.id,
data: data
});
});
peer.on('stream', (stream) => {
try {
this.userVideo.srcObject = stream;
} catch (e) {
this.userVideo.src = URL.createObjectURL(stream);
}
// this.userVideo.pause();
var playPromise =this.userVideo.play();
if (playPromise !== undefined) {
playPromise.then(_ => {
// Automatic playback started!
// Show playing UI.
})
.catch(error => {
// Auto-play was prevented
// Show paused UI.
});
}
});
peer.on('close', () => {
let peer = this.peers[userId];
if(peer !== undefined) {
peer.destroy();
}
this.peers[userId] = undefined;
});
return peer;
}
callTo(userId) {
this.peers[userId] = this.startPeer(userId);
}
render(){
return(
<div className="App">
{[1,2,3,4].map((userId) => {
return this.user.id !== userId ? <button key={userId} onClick={() => this.callTo(userId)}>Call {userId}</button> : null;
})}
<div className="video-container">
<video className="my-video" ref={(ref) => {this.myVideo = ref;}}></video>
<video className="user-video" ref={(ref) => {this.userVideo = ref;}}></video>
</div>
</div>
);
}
}
if (document.getElementById('app')) {
ReactDOM.render(<App />, document.getElementById('app'));
}
anyone help mee thanks in advance
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
peer.destroy() throws RTCErrorEvent · Issue #657 - GitHub
Uncaught RTCError : Transport channel closed and app.js:73056 Uncaught Error: Connection failed. at makeError (app.js:73056) at Peer.
Read more >Uncaught Error: Connection failed. rtcpeerconnection.t._pc ...
Here Is the Reactjs Component code It works fine in the same browser after deploying to heroku but when we join room from...
Read more >index.js:107 subscribe failed Error: connection failed. (v.4.3)
Hello Team, We are currently using Intel CS for WebRTC frame work v.4.2.1 and successfully rinning. Now, We installed v.4.3 on both CentOS...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There are many reasons this could happen. I’m not going to debug your code, sorry. If you can make reproducible demo or clearly define where is the issue in simple-peer itself that is fine, otherwise this is not a generic WebRTC support forum, so we can’t physically help everyone with their apps.
I am also facing this same issue