微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

错误:无法向服务器发送请求节点 php-fpm 本地主机

如何解决错误:无法向服务器发送请求节点 php-fpm 本地主机

fpm 库。我想集成 pubnub 并用它替换 socket io,但我的代码在 localhost 中不起作用。

到目前为止我做了什么

我已按照 this 在 xampp 中安装 fpm。我错过了什么?我该怎么做才能运行它?

安装后它工作了一次,但再次停止工作(没有更改代码中的任何内容)。

代码在实时服务器上运行良好。但在本地主机中我遇到以下错误

内容被剥离到错误:无法向服务器发送请求。但发现不对劲... 见下图

![enter image description here

这是我的代码

"use strict";

var PHPFPM = require('node-PHPfpm');
var striptags = require('striptags');
const log = require('simple-node-logger').createSimpleFileLogger(process.env.LOGDIR + '/poker-PHPwrapper.log');

class PHPWrapper {

    constructor(concierge) {
        this.PHPfpm = new PHPFPM({
            host: process.env.NODE_POKER_PHP_HOST,post: process.env.NODE_POKER_PHP_PORT,documentRoot: process.env.NODE_POKER_PHP_DOCROOT
        });

        this.concierge = concierge;
        this.busy = false;
    }

    houseKeeping(messages) {
        var PHP = this;
        PHP.busy = true;
        this.PHPfpm.run({
            uri: 'server_wrapper.PHP',json: {
                func: "houseKeeping",messages: messages
            }
        },function (err,body,PHPErrors) {
            PHP.busy = false;
            if (body.trim() == '') {
                return;
            }            
            // Check for PHP errors
            if (body.includes('<br />')) {
                // Get all the errors out until we've just got JSON left
                body = body.substring(body.indexOf('\n[')+1);
            }
            
            if (body.charat(0) != '[') {
                console.log('Stripped content to ' + body + " but found something wrong...");
            }
            
            try {
                var data = JSON.parse(body);
            } catch (parseError) {
                // throw("An error occurred parsing the JSON from PHP: " + parseError + "\nBody contents:\n" + body);
                data = '';
            }
            if (data.length == 0) {
                return;
            }
            for (var i in data) {
                if (data[i][0] == 'CONTROL') {
                    // Server control message,execute as appropriate
                    switch (data[i][1]) {
                        case 'force_exit': PHP.concierge.wipestateAndExit(); break;
                        case 'reset_server': PHP.concierge.wipestate(); break;
                    }
                } else {
                    // Message for client
                    PHP.concierge.msgToClient(data[i][0],data[i][1]);
                }
            }
        });
    }

    isBusy() {
        return this.busy;
    }

}

module.exports = PHPWrapper;

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。