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.

failed: Error during WebSocket handshake: Unexpected response code: 403

See original GitHub issue

my config

var express = require('express');
var proxy = require('http-proxy-middleware');

var wsProxy = proxy('/', {
	target: 'http://preview-hgpos.behuntergatherer.com',
	changeOrigin: true, // for vhosted sites, changes host header to match to target's host
	ws: true, // enable websocket proxy
	logLevel: 'debug'
})

var app = express()
app.use('/', express.static(__dirname))
app.use(wsProxy) // add the proxy to express

var server = app.listen(8070)
server.on('upgrade', wsProxy.upgrade) // optional: upgrade externally

my terminal

 Proxy created: /  ->  http://preview-hgpos.behuntergatherer.com
[HPM] Subscribed to http-proxy events:  [ 'error', 'close' ]
[DEMO] Server: listening on port 3000
[DEMO] Opening: http://localhost:3000
[HPM] GET /websocket/webSocketIMServer -> http://preview-hgpos.behuntergatherer.com
[HPM] Upgrading to WebSocket

browser console error

WebSocket connection to 'ws://localhost:8070/websocket/webSocketIMServer' failed: Error during WebSocket handshake: Unexpected response code: 403

I need help, Thx!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
aralcommented, Apr 18, 2019

To translate the last comment: “My problem has been solved because the backend framework restricts websocket requests from other domains, and the backend can be connected by removing the restrictions.”

0reactions
gauseencommented, May 7, 2021

@kellywang1234 不好意思,时间太久忘记了,好像是跨域的问题,配置一下 CORS 就可以了

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error during WebSocket handshake: Unexpected response code
WebSocket connection to 'ws://192.168.X.XYZ:8080/test' failed: Error during WebSocket handshake: Unexpected response code: 403.
Read more >
fixing [Error during WebSocket handshake: Unexpected ...
fixing [Error during WebSocket handshake: Unexpected response code: 403] when serving html from different server #644.
Read more >
Failed: Error during WebSocket handshake: Unexpected ...
Failed: Error during WebSocket handshake: Unexpected response code: 403 _initWebSocket ... Check your nginx conf - looks like your app cannot ...
Read more >
Error during WebSocket handshake: Unexpected response code
Hello everyone, I want to implement a notification system in my SAPUI5 application developed with SAP Web IDE.
Read more >
WebSocket : Unexpected response code: 403 - WordPress.org
WebSocket connection to 'wss://public-api.wordpress.com/pinghub/wpcom/me/newest-note-data' failed: Error during WebSocket handshake: Unexpected response ...
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