Im trying to send a json event through php using a Http client in the following way :
private function postEvent(Event $event) {
$client = $this->getHttpClient();
$client->setRawBody(json_encode($event));
$client->setUri($this->getHost() . '/api/events');
$client->setMethod('POST');
$client->send();
}
But I am facing the below error :
Fatal error: Uncaught exception 'ErrorException' with message 'stream_socket_client(): unable to connect to localhost:8080 (Connection refused)' in /home/naikr/www/public/fieldtest/vendor/zendframework/zend-http/Zend/Http/Client/Adapter/Socket.php on line 258
Zend\Http\Client\Adapter\Exception\RuntimeException: Unable to connect to localhost:8080 . Error #0: stream_socket_client(): unable to connect to localhost:8080 (Connection refused) in /home/naikr/www/public/fieldtest/vendor/zendframework/zend-http/Zend/Http/Client/Adapter/Socket.php on line 258
Any ideas on how I can resolve this and connect to localhost:8080 ?