Reputation: 1344
Hi i'm using Homestead with a laravel application.
I can't get the client to receive the data on from the server...
My socket.js:
var server = require('http').Server();
var io = require('socket.io')(server);
var Redis = require('ioredis');
var redis = new Redis();
redis.subscribe('test-channel');
redis.on('message', function (channel, message) {
message = JSON.parse(message);
io.emit(channel + ':' + message.event, message.data);
});
/*Booting Up the Server : port 3000 */
server.listen(3000 , function(){
console.log('The Server Is Running');
});
This is listening to port 3000 which is working. Console output:
vagrant@homestead:~/code/chatting-app$ nodemon -L socket.js
[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node socket.js`
The Server Is Running
On the client side i'm also listening to port 3000.
i use a piece of code to display the error:
function checkSocketIoConnect(url, timeout) {
return new Promise(function(resolve, reject) {
var errAlready = false;
timeout = timeout || 5000;
var socket = io(url, {reconnection: false, timeout: timeout});
// success
socket.on("connect", function() {
clearTimeout(timer);
resolve();
socket.close();
});
// set our own timeout in case the socket ends some other way than what we are listening for
var timer = setTimeout(function() {
timer = null;
error("local timeout");
}, timeout);
// common error handler
function error(data) {
if (timer) {
clearTimeout(timer);
timer = null;
}
if (!errAlready) {
errAlready = true;
reject(data);
socket.disconnect();
}
}
// errors
socket.on("connect_error", error);
socket.on("connect_timeout", error);
socket.on("error", error);
socket.on("disconnect", error);
});
}
checkSocketIoConnect("http://192.168.10.10:3000").then(function() {
console.log('succes');
}, function(reason) {
console.log(reason);
});
But this displays the following error:
Error: xhr poll error
Stacktrace:
[14]</n.prototype.onError@https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.7/socket.io.min.js:1:24221
[17]</</o.prototype.doPoll/<@https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.7/socket.io.min.js:1:29697
[9]</n.prototype.emit@https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.7/socket.io.min.js:1:13388
[17]</</i.prototype.onError@https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.7/socket.io.min.js:1:31004
i don't know what to do?! I tried everything i can think of.
My homestead.Yaml file:
Any help is appreciated...
Upvotes: 1
Views: 5678
Reputation: 1344
IT WAS ADBLOCKER
Disabled adblocker for this page and it works now.
Stupid.........
Upvotes: 2