小编Ale*_*cio的帖子

DigitalOcean 上的 NodeJS 服务器使用 socket.io 返回连接被拒绝

我试图将 socket.io 引入到我用 Laravel 和 AngularJS 开发的应用程序中。
该应用程序在我的计算机上运行良好,但是当我尝试使其在服务器上运行时,我收到错误“ GET http://localhost:8080/socket.io/?EIO=3&transport=polling&t=LQxpNjO net::ERR_CONNECTION_REFUSED ” 。

服务器运行的是 Ubuntu 16.04,我使用 nginx 作为 Web 服务器。

这是创建 Nodejs 服务器的文件:

var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var Redis = require('ioredis');
var redis = new Redis();

var port = 8080;

http.listen(port, function() {
  console.log('Listening on *:' + port);
});

io.on('connection', function (socket) {

  console.info('Client connected');

  redis.subscribe('counter.increase');

  redis.on('message', function (channel, message) {
    console.log('Received message ' + message + ' in channel ' + …
Run Code Online (Sandbox Code Playgroud)

nginx node.js socket.io laravel angularjs

4
推荐指数
1
解决办法
4052
查看次数

标签 统计

angularjs ×1

laravel ×1

nginx ×1

node.js ×1

socket.io ×1