1

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));      

            };            
Barry Michael Doyle
  • 9,333
  • 30
  • 83
  • 143
Gautam Mishra
  • 177
  • 2
  • 9
  • The question is possibled duplicate of http://stackoverflow.com/q/31873181 or http://stackoverflow.com/q/35035998 – Beck Yang Feb 25 '17 at 07:39

1 Answers1

0

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

Nehal J Wani
  • 16,071
  • 3
  • 64
  • 89
  • thanks for reply But now it is giving this error : "WebSocket connection to 'wss://webrtc-filetransfer.herokuapp.com/' failed: Error during WebSocket handshake: Unexpected response code: 503" – Gautam Mishra Feb 25 '17 at 09:58
  • I am Having error : Error during WebSocket handshake: Unexpected response code: 503" again . – Gautam Mishra Feb 26 '17 at 12:12
  • @GautamMishra 503 generally means service is unavailable. Check the server logs for more detail. – Nehal J Wani Feb 26 '17 at 12:21
  • -server is giving this message -- "2017-02-27T14:04:55.145930+00:00 heroku[router]: at=error code=H13 desc="Connect ion closed without response" method=GET path="/" host=webrtc-filetransfer.heroku app.com request_id=c380193d-441a-4ef8-aa9f-5278733cd7b1 fwd="45.115.188.116" dyn o=web.1 connect=0ms service=1ms status=503 bytes=0". – Gautam Mishra Feb 27 '17 at 14:06
  • I am unable to understand it . Please look at it !! – Gautam Mishra Feb 27 '17 at 14:07
  • @GautamMishra https://devcenter.heroku.com/articles/error-codes#h13-connection-closed-without-response – Nehal J Wani Feb 27 '17 at 19:18
  • did you find any solution? – Shivam Sahil Nov 18 '21 at 21:36