socket.io not working on client side (transport error)
<p>I am trying to implement sockets by following the tutorial <a href="https://laracasts.com/discuss/channels/general-discussion/step-by-step-guide-to-installing-socketio-and-broadcasting-events-with-laravel-51" rel="noreferrer">https://laracasts.com/discuss/channels/general-discussion/step-by-step-guide-to-installing-socketio-and-broadcasting-events-with-laravel-51</a> .
I got node.js running, reddis working and port 3000 is listening. I can get console messages on command line. Problem occurs when i try to emit anything to the client side.
Sever side:</p>

<pre><code>var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var Redis = require('ioredis');
var redis = new Redis();
redis.subscribe('test-channel', function(err, count) {
});
redis.on('message', function(channel, message) {
    console.log('Message Recieved: ' + message);
    message = JSON.parse(message);
    io.emit(channel + ':' + message.event, message.data);
});
http.listen(3000, function(){
    console.log('Listening on Port 3000');
});
</code></pre>

<p>Client side:</p>

<pre><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.7/socket.io.min.js"&gt;&lt;/script&gt;
&lt;script&gt;
    var socket = io('http://localhost:3000');
    //var socket = io('http://192.168.10.10:3000');
    socket.on("test-channel:App\\Events\\EventName", function(message){
        console.log("Working");
        // increase the power everytime we load test route
        $('#power').text(parseInt($('#power').text()) + parseInt(message.data.power));
    });
</code></pre>

<p>I tried to debug via browser console using "localStorage.debug = '*';"  and I receive the following message:</p>

<pre><code>engine.io-client:socket socket error {"type":"TransportError","description":{}} +4ms 
socket.io-client:manager connect_error +4ms 
socket.io-client:manager reconnect attempt error +1ms 
socket.io-client:manager will wait 5000ms before reconnect attempt +0ms 
engine.io-client:socket socket close with reason: "transport error" +1ms 
engine.io-client:polling transport not open - deferring close +1ms 
socket.io-client:manager attempting reconnect +5s 
socket.io-client:manager readyState closed +1ms
</code></pre>

<p>I tried all the available examples, I also tried the basic example from the socket.io website and nothing works. Any help is appreciated. Thanks</p>

<p>After few days digging I found out that socket.io works perfectly fine on localhost but does not work from extrernal domain. I also tried to change</p>

<pre><code>var socket = io('http://localhost:3000');
</code></pre>

<p>to</p>

<pre><code>var socket = io('http://serverip:3000');
</code></pre>

<p>but it did not help. Chrome browser gives me error:</p>

<pre><code>GET http://serverip:3000/socket.io/?EIO=3&amp;transport=polling&amp;t=LDrVJCA Request.create @ socket.io.min.js:1Request @ socket.io.min.js:1XHR.request @ socket.io.min.js:1XHR.doPoll @ socket.io.min.js:1Polling.poll @ socket.io.min.js:1Polling.doOpen @ socket.io.min.js:1Transport.open @ socket.io.min.js:1Socket.open @ socket.io.min.js:1Socket @ socket.io.min.js:1Socket @ socket.io.min.js:1Manager.open.Manager.connect @ socket.io.min.js:2(anonymous function) @ socket.io.min.js:3
feedTest:1 XMLHttpRequest cannot load http://serverip:3000/socket.io/?EIO=3&amp;transport=polling&amp;t=LDrVJCA. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://example.com' is therefore not allowed access. The response had HTTP status code 502.
</code></pre>

<p>I would really appreciate any help. Thanks</p>