我在Node.js的項目工作,我希望節點作爲代理行事的Solr插座掛斷,同時發佈請求節點-HTTP代理的Node.js
對於代理:我用Node-http-proxy。 問題是,代理工作具有優良的GET請求的情況下,但在POST請求它導致插座的情況下掛斷例外
這裏是我的結點代碼
var express = require('express');
var router = express.Router();
var http = require('http');
var httpProxy = require('http-proxy')
var proxyOptions = {
host: "127.0.0.1",
port: 8983
};
var proxy = httpProxy.createProxyServer(proxyOptions);
// It works excellent in GET request
router.get('/solr/*', function(req, res) {
proxy.web(req, res, {
target: 'http://' + proxyOptions.host + ':' + proxyOptions.port
});
})
// the socket hang up in post request
router.post('/solr/*', function(req, res) {
console.log('Post Request');
proxy.web(req, res, {
target: 'http://' + proxyOptions.host + ':' + proxyOptions.port
});
})
樣品,這是錯誤在節點控制檯一段時間後
Error: socket hang up
at createHangUpError (http.js:1476:15)
at Socket.socketOnEnd [as onend] (http.js:1572:23)
at Socket.g (events.js:180:16)
at Socket.emit (events.js:117:20)
at _stream_readable.js:943:16
at process._tickCallback (node.js:419:13)
這個問題的原因有什麼建議
https://github.com/nodejitsu/node-http-proxy/issues/180#issuecomment-12244852被用來做什麼用快遞 – alandarev 2014-10-29 14:38:36