Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php NodeJs无法侦听digital ocean Ubuntu上的端口_Php_Node.js_Nginx_Socket.io_Laravel 5.1 - Fatal编程技术网

Php NodeJs无法侦听digital ocean Ubuntu上的端口

Php NodeJs无法侦听digital ocean Ubuntu上的端口,php,node.js,nginx,socket.io,laravel-5.1,Php,Node.js,Nginx,Socket.io,Laravel 5.1,我正在尝试在我的服务器上实现消息传递。它是Ubuntu 14.04/Nginx 我已经安装了 1.nodejs 2.Redis 3.laravel 全部成功 当我运行命令时 node -v 它给了我node的版本 在我的控制器中,我的代码如下所示 public function sendMessage(){ $redis = LRedis::connection(); $redis->publish('message', 'Sending Mess

我正在尝试在我的服务器上实现消息传递。它是Ubuntu 14.04/Nginx

我已经安装了

1.nodejs 
2.Redis
3.laravel 
全部成功

当我运行命令时

node -v
它给了我node的版本

在我的控制器中,我的代码如下所示

public function sendMessage(){

        $redis = LRedis::connection();
        $redis->publish('message', 'Sending Message to Port');
        return redirect('writemessage');
    }
我的server.js代码是这样的

var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
var redis = require('redis');

server.listen(8890);
io.on('connection', function (socket) {

  console.log("new client connected");
  var redisClient = redis.createClient();
  redisClient.subscribe('message');

  redisClient.on("message", function(channel, message) {
    console.log("mew message in queue "+ message + "channel");
    socket.emit(channel, message);
  });

  socket.on('disconnect', function() {
    redisClient.quit();
  });

});
1458128671.226586 [0 127.0.0.1:59112] "SELECT" "0"
1458128671.232152 [0 127.0.0.1:59112] "PUBLISH" "message" "Sending Message to Port"
Redis服务器在默认6379上运行

为了收听广播,我的socket.php文件有以下代码

<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="https://cdn.socket.io/socket.io-1.3.4.js"></script>

    <script>
        var socket = io.connect('http://localhost:8890');
        socket.on('message', function (data) {
            $( "#messages" ).append( "<p>"+data+"</p>" );
          });
    </script>
但在节点端,我没有收到它


求你了!!“帮助我”

默认情况下,Digital Ocean关闭除80以外的所有端口

你需要先打开端口。你可以在这里找到解决办法


您的节点服务器是否在生产(Digital ocean)上成功运行?@Drudge在运行时没有任何错误,我也执行了
redis cli monitor
我可以看到我的消息是这样发布的
1458128671.226586[0 127.0.0.1:59112]“选择“0”1458128671.232152[0 127.0.0.1:59112]“发布”消息”“正在向端口发送消息“但是节点没有接收到它
您是否尝试访问url:with port?我猜节点服务器没有运行。Drudge这是url,
http://dev.iclock.in/writemessage
您可以在
http://dev.iclock.in/socket
,在我的代码中,我删除了输入值并硬编码了消息字符串,