Description
Is this a bug report?
Yes
Is this a feature request?
No
Steps to reproduce
Set up a proxy server with
app.use(
'/target1',
createProxyMiddleware('/target1', {
target: 'http://127.0.0.1:3000',
ws: true,
})
);
Expected behavior
On restarting target server.. and refreshing the client (establishing proxy req again) , the proxy should close the connection and start a new connection to target.
Actual behavior
(Write what happened.)
On restarting the target service the proxy service is crashing when client tries to connect... with the following error.
Error occurred while trying to proxy request /target1 from proxyserver to http://target1:8080 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
throw er; // Unhandled 'error' event
Error [ERR_STREAM_WRITE_AFTER_END]: write after end
at Socket.Writable.write (_stream_writable.js:296:5)
at writeAfterEnd (_stream_writable.js:248:12)
at Socket.end (net.js:548:31)
at ProxyServer.defaultErrorHandler (/home/node/app/node_modules/http-proxy-middleware/dist/handlers.js:59:9)
at Socket.Writable.end (_stream_writable.js:584:10)
at ClientRequest.onOutgoingError (/home/node/app/node_modules/http-proxy/lib/http-proxy/passes/ws-incoming.js:157:16)
at ClientRequest.emit (events.js:189:13)
at ProxyServer.emit (/home/node/app/node_modules/eventemitter3/index.js:204:33)
at Socket.socketOnEnd (_http_client.js:433:9)
at ClientRequest.EventEmitter.emit (domain.js:441:20)
at Socket.emit (events.js:194:15)
at Socket.EventEmitter.emit (domain.js:441:20)
at endReadableNT (_stream_readable.js:1129:12)
at /home/node/app/node_modules/async-listener/glue.js:188:31
at process.internalTickCallback (internal/process/next_tick.js:72:19)
Emitted 'error' event at:
at errorOrDestroy (internal/streams/destroy.js:98:12)
[... lines matching original stack trace ...]
at writeAfterEnd (_stream_writable.js:250:3)
at Socket.Writable.write (_stream_writable.js:296:5)
at process.internalTickCallback (internal/process/next_tick.js:72:19)
Setup
- http-proxy-middleware: 1.0.6
- http-proxy-middleware configuration: see above
- server: normal express server with socket.io
- other relevant modules
client info
Chrome browser.
target server info
Simple express server with socket.io