Getting error while trying to connect to a node server in php using elephantIO

I am trying to connect to a node server using ElephantIO in php

Here is the code

<?php
error_reporting(E_ALL);
ini_set('display_errors','On');

    use ElephantIO/Client,
        ElephantIO/Engine/SocketIO/Version1X,
        ElephantIO/Exception/ServerConnectionFailureException;

    require __DIR__ . '/vendor/autoload.php';

    $client = new Client(new Version1X('http://localhost:3001'));

    try
    {
        $client->initialize();
        $client->emit('new_order', ['foo' => 'bar']);
        $client->close();
    }
    catch (ServerConnectionFailureException $e)
    {
        echo $e;
    }

And i am getting an error on connection

ElephantIO/Exception/ServerConnectionFailureException: An error occurred while trying to establish a connection to the server in /var/www/html/Socket/vendor/wisembly/elephant.io/src/Engine/SocketIO/Version1X.php:167 Stack trace: #0 /var/www/html/Socket/vendor/wisembly/elephant.io/src/Engine/SocketIO/Version1X.php(48): ElephantIO/Engine/SocketIO/Version1X->handshake() #1 /var/www/html/Socket/vendor/wisembly/elephant.io/src/Client.php(60): ElephantIO/Engine/SocketIO/Version1X->connect() #2 /var/www/html/Socket/emit_test.php(47): ElephantIO/Client->initialize() #3 {main}