Hi all, We are writing a file uploading handler, by using formidable. Since the file could be large, say 50M, we want to cancel the uploading request if some necessary fields are missing or user quota exceeded, so user do not need to wait until the file is completely uploaded to see the response, and save our server from processing the unnecessary uploading request.
It works just fine. By using req.client.destroy() or res.connection.destroy(), the browser stops uploading immediately. Until we put it behind a reverse proxy nginx. The nginx server will firstly buffer the whole uploading body before it passes the control to our uploading handler, so we don't have a chance to cancel the uploading before it is completely uploaded. Then we use node-http-proxy to replace the nginx server, which will not buffer the request automatically. But after we cancel the request in the uploading handler, the reverse proxy node-http-proxy server will not do the same to the actual client, which means the browser is still busy uploading. Then we add a proxyError listener to the proxy, like this: server.proxy.on('proxyError', function(err, req, res){ console.log('proxyError:'); console.dir(err); if (err.code === 'ECONNRESET'){ res.connection.destroy(); } }); Sometimes, this will success, if the err is { [Error: socket hang up] code: 'ECONNRESET' }, the connection is successfully reset, and the browser stops uploading right away. But sometime not, if the err is { [Error: write ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'write' }, the res.connection.destroy() will just issue another proxyError: { [Error: write EPIPE] code: 'EPIPE', errno: 'EPIPE', syscall: 'write' }, and the browser continues it's uploading request. Are we doing something wrong here? Any suggestion is appreciated, thanks in advance. Regards, Mophy -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en