question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error during WebSocket handshake: Unexpected response code: 200

See original GitHub issue

I saw similar errors for code 400 and 404, but this one seems strange. After all, I would think a 200 code would mean “everything’s ok” right?

"peer": "^0.5.1", "peerjs": "^1.2.0"

On server side:

import { ExpressPeerServer } from 'peer'

const PeerController = {}

PeerController.initialize = function (app) {
  const peerServer = ExpressPeerServer(app, { debug: true, path: '/peerjs' })

  peerServer.on('connection', (client, foo) => {
    console.log(client, foo)
  })

  return peerServer
}

export default PeerController
const app = express()
app.use('/peer', PeerController.initialize(app))

And on the client side (a Vue application):

import Peer from 'peerjs'
export default {
  name: 'Meet',
  data () {
    return {
      peer: null
    }
  },
  mounted () {
    this.peer = new Peer('12345', {
      host: '/',
      port: '3000',
      path: '/peer/',
      debug: 3
    })
    this.peer.on('error', (err) => {
      console.debug(err)
    })
    this.peer.on('open', function (id) {
      console.log(id)
    })
  }
}

vendor.3921cbfb.js:18 WebSocket connection to 'ws://localhost:3000/peer/peerjs?key=peerjs&id=12345&token=697lo3pxz52' failed: Error during WebSocket handshake: Unexpected response code: 200

I noticed that it was 404ing initially until I added the path: '/peerjs' in the ExpressPeerServer constructor, because it seems that no matter what the client library tries to hit that endpoint. Not a huge worry, but after I solved the 404 issue I now get an “error” with a 200 code. Any advice? Thank you very much…

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
afrokickcommented, Mar 30, 2020

@baggachipz Anyway, join to our telegram chat) https://t.me/joinchat/ENhPuhTvhm8WlIxTjQf7Og

1reaction
baggachipzcommented, Mar 30, 2020

Looks like using the look-ahead regex worked. Might be handy to also allow passing in app instead of server, so that this is easier to handle. But thank you for your assistance!

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - WebSocket Handshake - Unexpected response code 200
withSockJS(); but unexpected error 200 was occuring. I've fixed this by appending /websocket to my client request string on the chrome ...
Read more >
wss: Error during WebSocket handshake: Unexpected ...
The strange thing is that you get a 200 status code. It seems that you are not hitting the WebSocket server as it...
Read more >
Error during WebSocket handshake: Unexpected response code
I have submitted a ticket (228750) already but not getting very prompt responses.
Read more >
Error during WebSocket handshake: Unexpected response code
I'm hitting some strange issues with this plugin currently on a client's website when trying to access the WP Live Chat Menu page....
Read more >
Websocket not proxied, client receives response code 200
In your Node.JS app, have you specified the usage of wss URLs? Make sure at Cloudflare dashboard → Network → WebSockets the option...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found