相关疑难解决方法(0)

在向Node-http-proxy Node.js发送请求时挂起套接字

我在Node.js项目中工作,我希望节点充当solr的代理

对于代理:我使用了Node-http-proxy.问题是,在获取请求的情况下代理工作非常好,但是在发出请求的情况下,它会导致套接字挂起异常

这是我的节点代码示例

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 + …
Run Code Online (Sandbox Code Playgroud)

javascript proxy solr node.js express

16
推荐指数
3
解决办法
1万
查看次数

套接字挂起错误Http-Proxy NodeJS

当用户单击"注销"按钮时,我的服务器控制台中出现以下错误.

Error: socket hang up
    at createHangUpError (http.js:1472:15)
    at Socket.socketCloseListener (http.js:1522:23)
    at Socket.EventEmitter.emit (events.js:95:17)
    at TCP.close (net.js:466:12)
Run Code Online (Sandbox Code Playgroud)

这是我的proxy_server:

var fs=require('fs');
var options = {
    key: fs.readFileSync('key/xxxxxxxxx.pem'),
    cert: fs.readFileSync('key/xxxxx.pem'),
    ca: fs.readFileSync('key/gd_bundle-g2-g1.crt')
};

var express=require('express'),
    https=require('https'),
    httpProxy = require('http-proxy'),
    http=require('http'),
    app=express(),
    app1=express(),
    server=https.createServer(options,app),
    serverhttp=http.createServer(app1);

var proxy = httpProxy.createProxy({ target: 'http://localhost:9898',secureOptions:'constants.SSL_OP_NO_TLSv1_2'});
var proxySig = httpProxy.createProxy({target:'http://localhost:8881',secureOptions:'constants.SSL_OP_NO_TLSv1_2'});
var callSig = httpProxy.createProxy({target:'http://localhost:6666',secureOptions:'constants.SSL_OP_NO_TLSv1_2'});
var proxyCdn = httpProxy.createProxy({target:'http://localhost:3030',secureOptions:'constants.SSL_OP_NO_TLSv1_2'});
// var proxyhttps= new httpProxy.createProxy({ target: 'https://localhost:443',secure:false});
var errorhandler = require('errorhandler');

app.all('*', function(req,res){
    if(req.hostname=='xxxxxxxx.in')
    {
        proxy.web(req, res); 
    }
    else if(req.hostname=='xxxx.in') …
Run Code Online (Sandbox Code Playgroud)

http-proxy node.js express socket.io

8
推荐指数
1
解决办法
3307
查看次数

标签 统计

express ×2

node.js ×2

http-proxy ×1

javascript ×1

proxy ×1

socket.io ×1

solr ×1