Open surjit opened 9 years ago
It's solved, thanks,
How did you solve it?
<?php
/*
namespace Igorw\EventSource;
/**
http://dev.w3.org/html5/eventsource/ */ class Stream { private $buffer; private $handler;
public function __construct($handler = null) { $this->buffer = new \SplQueue(); $this->buffer->setIteratorMode(\SplQueue::IT_MODE_DELETE); $this->handler = $handler ?: new EchoHandler(); }
public function event() { $event = new Event(); $this->buffer->enqueue($event);
$that = $this;
$wrapper = new EventWrapper($event, function () use ($that) {
return $that;
});
return $wrapper;
}
public function flush() { foreach ($this->buffer as $event) { $chunk = $event->dump(); if ('' !== $chunk) { call_user_func($this->handler, $chunk); } } }
public function getHandler() { return $this->handler; }
static public function setHeaders($headers = array()){ $headers = array_merge(self::getHeaders(), $headers); foreach ($headers as $name => $value) { header("$name: $value"); } }
static public function getHeaders() { return array( 'Content-Type' => 'text/event-stream', 'Transfer-Encoding' => 'identity', 'Cache-Control' => 'no-cache', 'X-Accel-Buffering' => 'no', 'Connection' => 'keep-alive', 'Access-Control-Allow-Origin' => '*' ); } }
EventSource's response has a MIME type ("text/html") that is not "text/event-stream". Aborting the connection. client.html:1
Fatal error: Uncaught exception 'Predis\Connection\ConnectionException' with message 'No connection could be made because the target machine actively refused it. [tcp://127.0.0.1:6379]' in vendor\predis\predis\src\Connection\AbstractConnection.php:146 Stack trace: #0 \vendor\predis\predis\src\Connection\StreamConnection.php(85): Predis\Connection\AbstractConnection->onConnectionError('No connection c...', 10061) #1 \vendor\predis\predis\src\Connection\StreamConnection.php(56): Predis\Connection\StreamConnection->tcpStreamInitializer(Object(Predis\Connection\Parameters)) #2 \vendor\predis\predis\src\Connection\AbstractConnection.php(95): Predis\Connection\StreamConnection->createResource() #3 \vendor\predis\predis\src\Connection\StreamConnection.php(142): Predis\Connection\AbstractConnection->connect() #4 in \vendor\predis\predis\src\Connection\AbstractConnection.php on line 146