0

I am using express with http-proxy in my application. There's one file upload API which takes more than 2 minutes because I am uploading a file which is to be processed in the backend. when I hit it from browser, I get 504 timeout error after around 50 seconds. I don't know who is causing it. Express or Node or http-proxy. How do I check it ? express code :-

'use strict'

const path = require('path')
const httpProxy = require('http-proxy')
const express = require('express')
const cookieParser = require('cookie-parser')
const app = express()
app.use(cookieParser())

app.use('/', express.static(path.resolve(__dirname, 'dist')))

const proxy = httpProxy.createProxyServer({ secure: false, proxyTimeout : 600000})

app.use('file-upload-api', (req, res) =>  {
proxy.web(req, res, { target: 'http://someurl' })})
})

app.use('/', express.static(path.resolve(__dirname, 'dist')))

var server = app.listen(6666, () => console.log('STARTED:', 6666, process.env.NODE_ENV));

path is like :- browser ---> express(node) ---> http-proxy ---> backend(java).

nir_sharma
  • 59
  • 8
  • Please provide more information. What does the endpoint do? some code would be nice – R. Gulbrandsen Feb 14 '17 at 11:27
  • from UI, I am uploading a file, which is to be processed in the actual backend. connection is like this :- browser ----> node(express) -----> http-proxy -------> Backend(Java). – nir_sharma Feb 14 '17 at 11:30
  • check that node is forwarding the upload properly, and setting correct Content-Length (or using correct chunking). 504 is gateway problem, so most likely coming from the proxy. – Adrien Feb 14 '17 at 23:01
  • @nir_sharma were you able to resolve this? please reply as I am facing same issue. – Faizan Shaikh Sarkar Feb 03 '22 at 16:34

0 Answers0