yiicod / yii2-socketio

46 stars 30 forks source link

Connection refused [tcp://127.0.0.1:6379] #21

Open durino13 opened 4 years ago

durino13 commented 4 years ago

I am trying to use socket.io in my project. Everything works locally ;) My browser establishes a connection with the node server and once I emit the event, I see it in the browser.

When I deploy the application on the server, I get following error: Connection refused [tcp://127.0.0.1:6379] It looks like some kind of process can't connect to the redis service running on this port. The sysadmin running the told me, that the service is running on that port (he event sent me some 'netstat') output, which proved that.

I have tried to use the 'predis' library and I wrote a piece of PHP code, which was able to connect to the service and the port: ` public function actionTest() { \Predis\Autoloader::register();

    try {
        $redis = new \Predis\Client();

        // This connection is for a remote server
        $redis = new \Predis\Client(array(
            "scheme" => "tcp",
            "host" => "localhost",
            "port" => 6379
        ));
        echo 'Connection successful';
    } catch (Exception $e) {
        die($e->getMessage());
    }
}`

When I execute this on the server, I get a 'connection successfull' message. I run these commands in order to start the socketio services: php yii socketio/php-server and php yii socketio/node-js-server .. I think socket should be OK, because I can see the connection in the browser developer tools (WS tab) and there are no errors in the console.

Any idea what could be the problem? I am lost ;(

ArtMin96 commented 3 years ago

I dont think you have installed a redis server yet ;)

https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-ubuntu-18-04