douao8204 2019-08-15 11:53
浏览 325

使用socket.io连接到Yii2

I have a Yii2 view and I want to run a socket.io port on it. The website is on a virtual host under name http:/yii.loc/. To run socket.io on my view I have the following code:

var socket = require('socket.io-client')('http://yii.loc');
var http = require('http').createServer(socket);

http.listen(3000, function(){
  console.log('listening on *:3000');
});

socket.on('connect', function(){
  console.log('connected!');
});

When I do node app.js, it console logs listening on *:3000 in Git Bash, but I still can't connect when going to http:/yii.loc/. I have tried http://yii.loc:3000/, but it doesn't load up. How can I run socket.io on my view?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 jupyterthemes 设置完毕后没有效果
    • ¥15 matlab图像高斯低通滤波
    • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
    • ¥15 钢筋实图交点识别,机器视觉代码
    • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
    • ¥50 400g qsfp 光模块iphy方案
    • ¥15 两块ADC0804用proteus仿真时,出现异常
    • ¥15 关于风控系统,如何去选择
    • ¥15 这款软件是什么?需要能满足我的需求
    • ¥15 SpringSecurityOauth2登陆前后request不一致