简体   繁体   English

套接字IO和MongoDB服务器

[英]Socket IO and MongoDB server

Today i installed MongoDB and Socket IO + Nodejs on Ubuntu (15.10) 今天,我在Ubuntu(15.10)上安装了MongoDB和Socket IO + Nodejs。

Everything is installed correctly, but my server.js (making a realtime chat) does not make any connection, This is the script i have: 一切都已正确安装,但是我的server.js(进行实时聊天)没有建立任何连接,这是我拥有的脚本:

var mongo = require('mongodb').MongoClient, client = require('socket.io').listen(8080).sockets;

client.on('connection', function(socket){
console.log('Someone has connected!');
});

Just nothing happends: 只是什么都没有发生:

在此处输入图片说明

Can anyone help me? 谁能帮我? THanks alot! 非常感谢!

From a tutorial i had to add 从教程中我必须添加

<Script src="http://127.0.0.1/socket.io/socket.io.js"></script>

But it says it cant find it altho its installed. 但是它说找不到安装的东西。

my Index: 我的索引:

在此处输入图片说明

  1. Make sure socket.io is installed 确保已安装socket.io

     npm install socket.io 
  2. As your server is not setup static files you should change the script src in your html to: 由于您的服务器未设置静态文件,因此应将html中的脚本src更改为:

     <script src="https://cdn.socket.io/socket.io-1.4.5.js"></script> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM