我正在使用socket.io开发Chating App。当我在本地主机应用程序上运行index.js文件完美工作并且用户与服务器节点文件连接时。但是当服务器和节点运行时index.js文件设置。节点开始了。但我试图通过应用程序连接套接字。用户没有连接.i也改变了IP和端口。
Index.js
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
io.on('connection', function(socket) {
console.log('A user connected');
socket.on("msgToClient", function(data) {
var sidd = data.sid;
console.log(sidd);
// sending to individual socketid (private message)
socket.to(sidd).emit('msgFromSever', {message: data.msg, socket_id: socket.id, adminID: data.adminLoginId, attachment:data.attachment});
})
socket.on('disconnect', function () {
console.log('A user disconnected');
});
});
http.listen(8000, function() {
console.log('Serve Start');
});
client side
import { SocketIoModule, SocketIoConfig, Socket } from 'ng-socket-io';
const config: SocketIoConfig = { url: 'http://162.210.70.9:8000/', options: {} };