Merge pull request #2330 from overleaf/bg-fix-realtime-proxy-exceptions

handle errors from realtime proxy connections

GitOrigin-RevId: 9259975b24fad789eddbe87f0cdfa706b10c1470
This commit is contained in:
Brian Gough 2019-11-06 14:40:19 +00:00 committed by sharelatex
parent 45cdb94f8a
commit 2c0c21554a

View file

@ -9,7 +9,7 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const settings = require('settings-sharelatex')
const logger = require('logger-sharelatex')
const httpProxy = require('http-proxy')
const proxy = httpProxy.createProxyServer({
target: settings.apis.realTime.url
@ -19,6 +19,13 @@ const wsProxy = httpProxy.createProxyServer({
ws: true
})
proxy.on('error', function(error) {
logger.err({ proxyError: error }, 'realtime http proxy error')
})
wsProxy.on('error', function(error) {
logger.err({ proxyError: error }, 'realtime ws proxy error')
})
module.exports = {
apply(webRouter, apiRouter) {
webRouter.all(/\/socket\.io\/.*/, (req, res, next) =>