peers / peerjs

Simple peer-to-peer with WebRTC.
https://peerjs.com
MIT License
12.48k stars 1.43k forks source link

Error during WebSocket handshake: Unexpected response code: 404 #445

Closed faienz93 closed 6 years ago

faienz93 commented 6 years ago

Hello everyone, i have finished my project using PeerJs and for test it i have decide to deploy the component of my project. For this, i deploy my server on Heroku. Regarding the client I have changed my point of access from const PEER_CLIENT = { HOST: "localhost", PORT: 9000, PATH: "/peerjs" }

to const PEER_CLIENT = { HOST: location.hostname, PORT: location.port || (location.protocol === 'https:' ? 443 : 80), PATH: "/peerjs" }

but I obtain the same error: WebSocket connection to 'wss://mydomain/peerjs/peerjs?key=peerjs&id=a-n2VPDPv&token=ztytk6x3mde' failed: Error during WebSocket handshake: Unexpected response code: 404

What is the problem ?

kidandcat commented 6 years ago

WebSocket connection to 'wss://mydomain/peerjs

You are trying to connect to a PeerServer in the domain "mydomain" which is not a valid domain name

I don't know why location.hostname is being populated with "mydomain"

faienz93 commented 6 years ago

mmm no, "my domain" is a github pages of my project. Now i change the domain with the url of my server and i post the result.

faienz93 commented 6 years ago

ok, i have resolved. Setting as HOST the url of my server and setting the port on 443 the connection is establish.

Best regards Antonio Faienza

ghost commented 5 years ago

i am facing some issue few days, anybody please help me failed: Error during WebSocket handshake: Unexpected response code: 404 in this file main-unminified.js

allanyego commented 4 years ago

ok, i have resolved. Setting as HOST the url of my server and setting the port on 443 the connection is establish.

Best regards Antonio Faienza

Doesn't work on Heroku. I get permission errors.

tajammal-husnain commented 4 years ago

@yegow it works on Heroku server hosted too,while creating peer, const newPeer = new Peer(id, { host:'youdomain.com',
port: 443, secure: true });