Reputation: 177
I am new to node js development and i am using webrtc. My app is working correctly on localhost (on my pc) but on heroku server it is giving me this error:
"WebSocket connection to 'wss://https//webrtc-filetransfer.herokuapp.com/' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED WrappedWebSocket @ VM72:35 (anonymous) @ main1.js:20".
server side web socket code
var express = require('express');
var bodyparser = require('body-parser');
var app = express();
app.listen(process.env.PORT || 3000);
app.use(express.static('client'));
app.use(bodyparser.json());
var SERVER_PORT = 8087 ;
var WebSocketServer = require('ws').Server , wss = new WebSocketServer({port :8087});
console.log("server_started");
Client Side Code is
var ws = new WebSocket('wss:/https://webrtc-filetransfer.herokuapp.com/');
ws.onopen = function()
{
// Web Socket is connected, send data using send()
var data={
mid:"login",
uid: myId
};
ws.send(JSON.stringify(data));
};
Upvotes: 1
Views: 4648
Reputation: 16639
Replace...
wss://https//webrtc-filetransfer.herokuapp.com/
...with:
wss://webrtc-filetransfer.herokuapp.com/
Specifying wss
automatically tells a WebSocket client library to use https
to connect to a WebSocket server. You don't need to further specify https
in the URI
Upvotes: 0