套接字挂断错误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)

这是我的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')
    {
        proxyCdn.web(req, res);
    }
    else if(req.hostname=='xxxxxx.in')
    {
        proxySig.web(req, res); 
    }
    else if(req.hostname=='xxxxx.in')
    {
        callSig.web(req, res); 
    }
});

app1.all('*', function(req,res){
    res.redirect('https://'+req.hostname);;
});

serverhttp.listen(80);
server.listen(443);
约翰·加兰博斯

您需要处理每个httpProxy对象上的错误。例如:

proxy.on('error', function (error, req, res) {
    var json;
    console.log('proxy error', error);
    if (!res.headersSent) {
        res.writeHead(500, { 'content-type': 'application/json' });
    }

    json = { error: 'proxy_error', reason: error.message };
    res.end(JSON.stringify(json));
});

该线程对我有用:https : //github.com/nodejitsu/node-http-proxy/issues/527

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

/node_modules/http-proxy/lib/http-proxy/index.js:120; 错误:套接字挂断

来自分类Dev

发送请求时,nodejs套接字挂断

来自分类Dev

将请求发布到Node-http-proxy Node.js时发生套接字挂断

来自分类Dev

套接字挂断错误与多个http.get请求

来自分类Dev

Simple Proxy Server with NodeJs

来自分类Dev

请求期间出现“套接字挂断”错误

来自分类Dev

Express出现“错误:套接字挂断”

来自分类Dev

Express出现“错误:套接字挂断”

来自分类Dev

Nodejs和套接字io错误:监听EADDRINUSE

来自分类Dev

nodejs https错误:套接字与本地主机挂起

来自分类Dev

使用Node HTTP请求从GitHub API进行套接字挂断错误

来自分类Dev

nodejs tcp套接字写

来自分类Dev

性能套接字nodejs + mysql

来自分类Dev

MongoError:套接字挂断

来自分类Dev

Virtualbox 套接字挂断

来自分类Dev

使用node-http-proxy从NodeJS到Apache的反向代理不起作用

来自分类Dev

如何在http-proxy-middleware函数内的NodeJS中发出终止请求?

来自分类Dev

对外部API的https请求上的套接字挂断错误?

来自分类Dev

错误:套接字使用节点v0.12.0挂断

来自分类Dev

为什么会收到“错误套接字挂断”响应?

来自分类Dev

Node.js https.request()错误:套接字挂断

来自分类Dev

异步函数抛出错误:套接字挂断

来自分类Dev

云函数返回 RequestError:错误:套接字挂断

来自分类Dev

请求计数的增加以“错误:套接字挂断”告终

来自分类Dev

带有 Firebase Cloud Functions 错误的 SendGrid:“套接字挂断”

来自分类Dev

NodeJS 0.10.46 not serving after lighttpd proxy anymore

来自分类Dev

支持子目录的Apache / NodeJS / Proxy

来自分类Dev

Nodejs Winston发射到套接字

来自分类Dev

NodeJS + SocketIO大套接字事件管理

Related 相关文章

热门标签

归档