Comments (12)
Thank for reporting it.
I encountered the same issue while implementing the websocket proxy.
This issue only occurs when you use browser-sync; Don't have this issue with connect and express.
Which version of browser-sync are you using?
from http-proxy-middleware.
hey, thanks for the response.
2.7.12
from http-proxy-middleware.
any luck on this ? /me pushes his luck ...
from http-proxy-middleware.
No luck unfortunately...
I tested it with the latest 2.8.2 version and I'm getting the same result.
I suspect it is an issue in browser-sync; A similar issue has been reported: BrowserSync/browser-sync#625 for their own proxy option.
They've solved it for browser-sync's option.proxy and websockets.
However, when you use browser-sync's option.server (just like your example) with http-proxy-middleware; it doesn't work if you need to proxy websockets too.
This issue might be related to what they have fixed for their option.proxy.
You might want to open a ticket @ BrowserSync. Hopefully they can verify if it actually is an issue in browser-sync's option.server.
from http-proxy-middleware.
I would have to agree, I am just getting back to this now and @chimurai I have to say this is great work on this module.
I found it easier to just switch from browserSync to express and be done with it.
from http-proxy-middleware.
Thanks @DefunctExodus :)
Bumped into this issue since the day I started implementing support for WebSockets.
Hopefully it can be solved one day....
from http-proxy-middleware.
@DefunctExodus : could you explain how you moved from BrowserSync to plain express ? What issues did you face - does (for example) live reload work properly ?
from http-proxy-middleware.
I am trying to work around this problem by using express in my Gulp serve task and opening an ad-hoc websocket proxy on a different port than BrowserSync.
So BrowserSync is running on port 8081. My backend (java) on port 8080. And the 'special' websocket proxy is running on 8082:
var wsProxy = express();
wsProxy.use('/tango-ws', proxy({
target: 'http://localhost:8080/tango-ws',
changeOrigin: true,
ws : true,
prependPath: false,
logLevel : 'debug'
}));
wsProxy.listen(8082);
My client makes tries to connect to the proxy on the port 8082, but I still get the same error:
VM61:35 WebSocket connection to 'ws://localhost:8082/tango-ws' failed: Connection closed before receiving a handshake response
Had anyone had any luck proxying websockets from a Gulp task ?
from http-proxy-middleware.
@HereThereBeMonsters I did have some luck.
I had an express instance running the backend AND serving the files. I then used the proxy option of browserSync directly and that worked like such:
browserSync.init({
proxy: 'http://localhost:' + port,
port: port + 1,
ws: true,
ui: {
port: port + 3
}
});
Where port was the port of the express server.
Now when the backend and file server are separate I have zero luck.
from http-proxy-middleware.
@julbra : thanks for the input. I need it with BrowserSync serving the files, so in "server" mode so it seems that I wont be able to do it. For now I will just hit the backend directly and I'll have to remove the same-origin check on the WebSocket endpoint.
from http-proxy-middleware.
Any update for this issue?
from http-proxy-middleware.
Any update on this?
from http-proxy-middleware.
Related Issues (20)
- req.url is always '/' HOT 4
- Fails to proxy from localhost to localhost HOT 2
- Too many subscriptions to Server.close event cause a OOM? HOT 4
- TS type compatibility HOT 4
- ERR_HTTP_HEADERS_SENT from onProxyReq with https-proxy-agent HOT 2
- Proxy to another proxy HOT 1
- Security Vulnerability in Dependency | follow-redirects HOT 2
- "Invalid context" error message is unhelpful when mixing paths with globs HOT 1
- Release plan for v3.0.0 HOT 1
- Response interceptor copyHeaders logic only removes first character of cookie domain because of non-greedy regex
- TypeError: (options.buffer || req).pipe is not a function HOT 1
- Allow custom Http Method like LIST HOT 3
- SSE close connection issue with proxy HOT 3
- V3: base path not stripped from WebSocket upgrade requests HOT 2
- SSL Error in when Upgrading from node 16 to 18 HOT 3
- Setting followRedirects to true limits the form-data body size length to 10 MB
- Removes port from target HOT 9
- Hono Support for http-proxy-middleware HOT 1
- The Cookie header is not being included in the redirected address. HOT 2
- How to reduce logger to only errors? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from http-proxy-middleware.