Sending request to websocket takes forever.
I created basic websocket php to check and when i call the test file. The request take forever to complete. I followed the guide from official docs (http://socketo.me/docs). 

I am calling this php to start a websockets.

```
<?php 
// API for privacy setting of user for blocking/Message Limit
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
//file_put_contents('zee.log',print_r($_POST,true));

// Function to send the SDP and user IDs to the server
function sendSDP($sdp, $userIdA, $userIdB)
{
    // Create a new cURL resource
    $ch = curl_init();

    // Set the cURL options
    curl_setopt($ch, CURLOPT_URL, "callSocketChat_2008.php");  `callSocketChat_2008.php` file
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(
        'sdp' => $sdp,
        'userIdA' => $userIdA,
        'userIdB' => $userIdB
    )));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    // Execute the cURL request
    $response = curl_exec($ch);

    // Check for errors
    if ($response === false) {
        echo "cURL Error: " . curl_error($ch);
    } else {
        // Request successful, display the response
        echo $response;
    }

    // Close the cURL resource
    curl_close($ch);
}

// Test the sendSDP function
$sdp = "SDP valuexx YY"; // Replace with your actual SDP value
$userIdA = "4"; // Replace with your actual User ID A value
$userIdB = "8"; // Replace with your actual User ID B value

sendSDP($sdp, $userIdA, $userIdB);


?>
```

This is the Ratchet file where i am creating the socket.

```
<?php
// Enable error reporting and display errors for debugging purposes
error_reporting(E_ALL);
ini_set('display_errors', 1);

require_once("/home/bitnami/vendor/autoload.php");
use Ratchet\MessageComponentInterface;;
use Ratchet\ConnectionInterface;

class WebSocketHandler implements MessageComponentInterface {
    protected $clients;

    public function __construct() {
        $this->clients = new \SplObjectStorage();
		print_r("Print Value ");
    }

    public function onOpen(ConnectionInterface $conn) {
        // Handle new WebSocket connection
        // You can add the connection to $this->clients for future reference
		//$request = $conn->httpRequest;
        //$userId = $_POST['userId']; // Assuming the user ID is received in the POST request

        // Save the user ID in the resourceId property of the connection
        $conn->resourceId = $userIdA;

        // Add the connection to the clients list
        $this->clients->attach($conn);
        echo "New connection! ({$conn->resourceId})\n";
    }

    public function onMessage(ConnectionInterface $from, $msg) {
        // Handle incoming WebSocket message
        // You can process the message and send a response back to the client
    }

    public function onClose(ConnectionInterface $conn) {
        // Handle WebSocket connection close
        // You can remove the connection from $this->clients if necessary
	    $this->clients->detach($conn);
    }

    public function onError(ConnectionInterface $conn, \Exception $e) {
        // Handle WebSocket error
        // You can log or handle the error as needed
    }
}



// Get the SDP and user IDs from the request
$sdp = $_POST['sdp'];
$userIdA = $_POST['userIdA'];
$userIdB = $_POST['userIdB'];

// Fetch user details from the elaxer database using the user IDs
$userDetailsA = fetchUserDetails($userIdA);
$userDetailsB = fetchUserDetails($userIdB);

// Send push notification to wake up User B's device
//sendPushNotification($userDetailsB['fcmToken']);

// Wait for User B's device to establish a WebSocket connection
$waitForConnectionTimeout = 30; // Timeout in seconds
$startTime = time();
while (time() - $startTime < $waitForConnectionTimeout) {
    // Check if User B's device has connected to the WebSocket
    if (userDeviceConnected($userIdB)) {
        // User B's device connected, retrieve SDP from the elaxer database
        $sdpB = fetchSDP($userIdB);

        // Save User A's SDP in the elaxer database
        saveSDP($userIdA, $sdp);

        // Return User B's SDP to User A
        echo $sdpB;
        exit;
    }

    // Wait for a short duration before checking again
    sleep(1);
}


// Instantiate WebSocketHandler

//$server = \Ratchet\Server\IoServer::factory(
  //  new \Ratchet\Http\HttpServer(
    //    new \Ratchet\WebSocket\WsServer($webSocketHandler)
    //),
    //8080 // Change the port number if needed
//);

// Set up the WebSocket server using Ratchet
$server = Ratchet\Server\IoServer::factory(new WebSocketHandler(),20081); // Change the port number if needed
$server->run();




// Timeout reached, handle the case when User B's device didn't connect
handleTimeout();

// Fetch user details from the elaxer database using the user ID
function fetchUserDetails($userId)
{
    // Implement the logic to fetch user details from the elaxer database
    // Return an array containing the user details
}

// Send push notification to wake up User B's device
function sendPushNotification($fcmToken)
{
    // Implement the logic to send a push notification using FCM to the specified FCM token
}

// Check if User B's device has connected to the WebSocket
function userDeviceConnected($userId)
{
    // Implement the logic to check if User B's device has connected to the WebSocket
    // Return true if the device is connected, false otherwise
}

// Fetch SDP from the elaxer database using the user ID
function fetchSDP($userId)
{
    // Implement the logic to fetch SDP from the elaxer database using the user ID
    // Return the retrieved SDP
}

// Save SDP in the elaxer database using the user ID
function saveSDP($userId, $sdp)
{
    // Implement the logic to save the SDP in the elaxer database using the user ID
}

// Handle the case when User B's device didn't connect within the timeout
function handleTimeout()
{
    // Implement the logic to handle the timeout case
    // For example, you can return an error response or perform a fallback action
}


?>
```


I call the test file from postman and postman stuck at sending response.... prompt. 
When i call  `netstat -anp | grep LISTEN` to check open ports mentioned in the above code, present in the list of open ports when request still waiting for the reply from onOpen.  
There must be some issue with my code and i missed something from the official docs. Please help me and let me know if i miss anything.

