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?