Coder Social home page Coder Social logo

freddie's Introduction

Application Coverage

Freddie

Freddie is a PHP implementation of the Mercure Hub Specification.

It is blazing fast, built on the shoulders of giants:

See what features are covered and what aren't (yet) here.

Installation

PHP 8.1+ is required to run the hub.

As a standalone Mercure hub

composer create-project freddie/mercure-x freddie && cd freddie
bin/freddie

This will start a Freddie instance on 127.0.0.1:8080, with anonymous subscriptions enabled.

You can publish updates to the hub by generating a valid JWT signed with the !ChangeMe! key with HMAC SHA256 algorithm.

To change these values, see Security.

As a bundle of your existing Symfony application

composer req freddie/mercure-x

You can then start the hub by doing:

bin/console freddie:serve

You can override relevant env vars in your .env.local and services in your config/services.yaml as usual.

Then, you can inject Freddie\Hub\HubInterface in your services so that you can call $hub->publish($update), or listening to dispatched updates in a CLI context ๐Ÿ‘

Keep in mind this only works when using the Redis transport.

โš ๏ธ Freddie uses its own routing/authentication system (because of async / event loop).

The controllers it exposes cannot be imported in your routes.yaml, and get out of your security.yaml scope.

Usage

./bin/freddie

It will start a new Mercure hub on 127.0.0.1:8080. To change this address, use the X_LISTEN environment variable:

X_LISTEN="0.0.0.0:8000" ./bin/freddie

Security

The default JWT key is !ChangeMe! with a HS256 signature.

You can set different values by changing the environment variables (in .env.local or at the OS level): X_LISTEN, JWT_SECRET_KEY, JWT_ALGORITHM, JWT_PUBLIC_KEY and JWT_PASSPHRASE (when using RS512 or ECDSA)

Please refer to the authorization section of the Mercure specification to authenticate as a publisher and/or a subscriber.

PHP Transport (default)

By default, the hub will run as a simple event-dispatcher, in a single PHP process.

It can fit common needs for a basic usage, but using this transport prevents scalability, as opening another process won't share the same event emitter.

It's still prefectly usable as soon as :

  • You don't expect more than a few hundreds updates per second
  • Your application is served from a single server.

Redis transport

On the other hand, you can launch the hub on multiple ports and/or multiple servers with a Redis transport (as soon as they share the same Redis instance), and optionally use a load-balancer to distribute the traffic.

The official open-source version of the hub doesn't allow scaling because of concurrency restrictions on the bolt transport.

To launch the hub with the Redis transport, change the TRANSPORT_DSN environment variable:

TRANSPORT_DSN="redis://127.0.0.1:6379" ./bin/freddie

Optional parameters you can pass in the DSN's query string:

  • pingInterval - regularly ping Redis connection, which will help detect outages (default 2.0)
  • readTimeout - max duration in seconds of a ping or publish request (default 0.0: considered disabled)

Alternatively, you can set this variable into .env.local.

Advantages and limitations

This implementation does not provide SSL nor HTTP2 termination, so you'd better put a reverse proxy in front of it.

Example Nginx configuration

upstream freddie {
    # Example with a single node
    server 127.0.0.1:8080;

    # Example with several nodes (they must share the same Redis instance)
    # 2 instances on 10.1.2.3
    server 10.1.2.3:8080;
    server 10.1.2.3:8081;

    # 2 instances on 10.1.2.4
    server 10.1.2.4:8080;
    server 10.1.2.4:8081;
}

server {
    
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name example.com;

    ssl_certificate /etc/ssl/certs/example.com/example.com.cert;
    ssl_certificate_key /etc/ssl/certs/example.com/example.com.key;
    ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;

    location /.well-known/mercure {
        proxy_pass http://freddie;
        proxy_read_timeout 24h;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Example Caddy configuration

Single node

example.com

reverse_proxy 127.0.0.1:8080

With multiple nodes

example.com

reverse_proxy 10.1.2.3:8080 10.1.2.3:8081 10.1.2.4:8080 10.1.2.4:8081

Payload limitations

โš  There's a known limit in Framework-X which prevents request bodies to weigh more than 64 KB. At the time of writing, this limit cannot be raised due to Framework-X encapsulating HTTP Server instantiation.

Publishing bigger updates to Freddie (through HTTP, at least) could result in 400 errors.

Feature coverage

Feature Covered
JWT through Authorization header โœ…
JWT through mercureAuthorization Cookie โœ…
Allow anonymous subscribers โœ…
Alternate topics โœ…๏ธ
Private updates โœ…
URI Templates for topics โœ…
HMAC SHA256 JWT signatures โœ…
RS512 JWT signatures โœ…
Environment variables configuration โœ…
Custom message IDs โœ…
Last event ID (including earliest) โœ…๏ธ
Customizable event type โœ…๏ธ
Customizable retry directive โœ…๏ธ
CORS โŒ (configure them on your web server)
Health check endpoint โŒ (PR welcome)
Logging โŒ (PR welcome))๏ธ
Metrics โŒ (PR welcome)๏ธ
Different JWTs for subscribers / publishers โŒ (PR welcome)
Subscription API โŒ๏ธ (TODO)

Tests

This project is 100% covered with Pest tests.

composer tests:run

Contribute

If you want to improve this project, feel free to submit PRs:

  • CI will yell if you don't follow PSR-12 coding standards
  • In the case of a new feature, it must come along with tests
  • PHPStan analysis must pass at level 8

You can run the following command before committing to ensure all CI requirements are successfully met:

composer ci:check

License

GNU General Public License v3.0.

freddie's People

Contributors

bpolaszek avatar koulouklegrand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

freddie's Issues

Performance degradation over time

Hi, first of all, congrats for your amazing project!

I noticed that every connection on the hub register a callback:

public function subscribe(callable $callback): void
{
    $this->init();
    $this->subscriber->on('message', function (string $channel, string $payload) use ($callback) {
        $callback($this->serializer->deserialize($payload));
    });
}

After the client close the connection, the callback remains there.

So, after few hours and hundreds of thousands of subscribes, the performance gets terrible, since every publish has to call hundreds of thousands functions, mostly unecessary (subscriber has long gone).

The solution is to listen connection e close events, register an array of subscribers (address => $callback()), and then remove them on connection close.

That's how the original implementation works: https://github.com/dunglas/mercure/blob/main/subscribe.go

Install fails with Composer inside Symfony application

Hi,

I am trying to download this package through Composer.

This is what I get:

Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Restricting packages listed in "symfony/symfony" to "6.0.*"
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires freddie/mercure-x 0.2 -> satisfiable by freddie/mercure-x[0.2].
    - freddie/mercure-x 0.2 requires clue/framework-x dev-main -> found clue/framework-x[dev-main] but it does not match your minimum-stability.

If I try to set my minimum-stability to "dev", here is the error:

Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Restricting packages listed in "symfony/symfony" to "6.0.*"
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires freddie/mercure-x 0.2 -> satisfiable by freddie/mercure-x[0.2].
    - freddie/mercure-x 0.2 requires react/async dev-main -> found react/async[v1.0.0, 2.x-dev, 3.x-dev, 4.x-dev] but it does not match the constraint.

How can I address this issue?

Nginx upstream reverse proxy pending request

Hi everyone.

I'm getting a error using the nginx reverse proxy for freddie bundle, the response from subscriber controller remains pending and i cant get he response header status.

If i sent a request direclty to react server the response header is running.


Request URL:
http://localhost:4001/.well-known/mercure?topic=test
Request Method:
GET
Status Code:
200 OK
Remote Address:
[::1]:4001
Referrer Policy:
strict-origin-when-cross-origin

HTTP/1.1 200 OK
Content-Type: text/event-stream
Server: ReactPHP/1
Date: Sun, 29 Oct 2023 17:41:06 GMT
Transfer-Encoding: chunked

But, if I send a request to the nginx server i cant receive a response from the server, the Chrome DevTools inform the pendins status.

Request URL:
http://localhost:4000/.well-known/mercure?topic=test
Referrer Policy:
strict-origin-when-cross-origin  

Follow my nginx configuration

upstream freddie {
    server 127.0.0.1:4001;
}

server {

    listen 4000;
    server_name _;

    location / {
        # Simple requests
        if ($request_method ~* "(GET|POST)") {
          add_header "Access-Control-Allow-Origin"  *;
        }

        # Preflighted requests
        if ($request_method = OPTIONS ) {
          add_header "Access-Control-Allow-Origin"  *;
          add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD";
          add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept";
          return 200;
        }

        proxy_pass http://freddie;
        proxy_read_timeout 24h;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Follow nginx debug log:

2023/10/29 18:08:59 [debug] 29#29: *3 http run request: "/.well-known/mercure?topic=test"
2023/10/29 18:08:59 [debug] 29#29: *3 http upstream check client, write event:0, "/.well-known/mercure"
**2023/10/29 18:08:59 [info] 29#29: *3 epoll_wait() reported that client prematurely closed connection, so upstream connection is closed too while reading upstream, client: 192.168.0.1, server: _, request: "GET /.well-known/mercure?topic=test HTTP/1.1",** upstream: "http://127.0.0.1:4001/.well-known/mercure?topic=test", host: "localhost:4000"
2023/10/29 18:08:59 [debug] 29#29: *3 finalize http upstream request: 499
2023/10/29 18:08:59 [debug] 29#29: *3 finalize http proxy request
2023/10/29 18:08:59 [debug] 29#29: *3 free rr peer 1 0
2023/10/29 18:08:59 [debug] 29#29: *3 close http upstream connection: 19
2023/10/29 18:08:59 [debug] 29#29: *3 free: 000055BC9DB54E60, unused: 48
2023/10/29 18:08:59 [debug] 29#29: *3 event timer del: 19: 216919881
2023/10/29 18:08:59 [debug] 29#29: *3 reusable connection: 0
2023/10/29 18:08:59 [debug] 29#29: *3 http upstream temp fd: -1
2023/10/29 18:08:59 [debug] 29#29: *3 http finalize request: 499, "/.well-known/mercure?topic=test" a:1, c:1
2023/10/29 18:08:59 [debug] 29#29: *3 http terminate request count:1
2023/10/29 18:08:59 [debug] 29#29: *3 http terminate cleanup count:1 blk:0
2023/10/29 18:08:59 [debug] 29#29: *3 http posted request: "/.well-known/mercure?topic=test"
2023/10/29 18:08:59 [debug] 29#29: *3 http terminate handler count:1
2023/10/29 18:08:59 [debug] 29#29: *3 http request count:1 blk:0
2023/10/29 18:08:59 [debug] 29#29: *3 http close request
2023/10/29 18:08:59 [debug] 29#29: *3 http log handler
2023/10/29 18:08:59 [debug] 29#29: *3 geoip2 http log handler
2023/10/29 18:08:59 [debug] 29#29: *3 free: 000055BC9DB72CB0
2023/10/29 18:08:59 [debug] 29#29: *3 free: 000055BC9DBCA870, unused: 2
2023/10/29 18:08:59 [debug] 29#29: *3 free: 000055BC9DBB8A00, unused: 5
2023/10/29 18:08:59 [debug] 29#29: *3 free: 000055BC9DB73CC0, unused: 3022
2023/10/29 18:08:59 [debug] 29#29: *3 close http connection: 21
2023/10/29 18:08:59 [debug] 29#29: *3 reusable connection: 0
2023/10/29 18:08:59 [debug] 29#29: *3 free: 000055BC9DB6DA90
2023/10/29 18:08:59 [debug] 29#29: *3 free: 000055BC9DB6B230, unused: 136
2023/10/29 18:08:59 [debug] 29#29: accept on 0.0.0.0:4000, ready: 0
2023/10/29 18:08:59 [debug] 29#29: posix_memalign: 000055BC9DB6B230:512 @16
2023/10/29 18:08:59 [debug] 29#29: *6 accept: 192.168.0.1:57462 fd:19
2023/10/29 18:08:59 [debug] 29#29: *6 event timer add: 19: 60000:130773327
2023/10/29 18:08:59 [debug] 29#29: *6 reusable connection: 1
2023/10/29 18:08:59 [debug] 29#29: *6 epoll add event: fd:19 op:1 ev:80002001
2023/10/29 18:08:59 [debug] 29#29: *6 http wait request handler
2023/10/29 18:08:59 [debug] 29#29: *6 malloc: 000055BC9DB6DA90:1024
2023/10/29 18:08:59 [debug] 29#29: *6 recv: eof:0, avail:-1
2023/10/29 18:08:59 [debug] 29#29: *6 recv: fd:19 702 of 1024
2023/10/29 18:08:59 [debug] 29#29: *6 reusable connection: 0
2023/10/29 18:08:59 [debug] 29#29: *6 posix_memalign: 000055BC9DBCA870:4096 @16
2023/10/29 18:08:59 [debug] 29#29: *6 http process request line
2023/10/29 18:08:59 [debug] 29#29: *6 http request line: "GET /.well-known/mercure?topic=test HTTP/1.1"
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'2F:/'
2023/10/29 18:08:59 [debug] 29#29: *6 s:1 in:'2E:.'
2023/10/29 18:08:59 [debug] 29#29: *6 s:2 in:'77:w'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'65:e'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'6C:l'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'6C:l'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'2D:-'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'6B:k'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'6E:n'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'6F:o'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'77:w'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'6E:n'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'2F:/'
2023/10/29 18:08:59 [debug] 29#29: *6 s:1 in:'6D:m'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'65:e'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'72:r'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'63:c'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'75:u'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'72:r'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'65:e'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'3F:?'
2023/10/29 18:08:59 [debug] 29#29: *6 http uri: "/.well-known/mercure"
2023/10/29 18:08:59 [debug] 29#29: *6 http args: "topic=test"
2023/10/29 18:08:59 [debug] 29#29: *6 http exten: ""
2023/10/29 18:08:59 [debug] 29#29: *6 posix_memalign: 000055BC9DBB8A00:4096 @16
2023/10/29 18:08:59 [debug] 29#29: *6 http process request header line
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Host: localhost:4000"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Connection: keep-alive"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Cache-Control: max-age=0"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "sec-ch-ua: "Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99""
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "sec-ch-ua-mobile: ?0"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "sec-ch-ua-platform: "Linux""
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Upgrade-Insecure-Requests: 1"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Sec-Fetch-Site: none"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Sec-Fetch-Mode: navigate"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Sec-Fetch-User: ?1"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Sec-Fetch-Dest: document"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Accept-Encoding: gzip, deflate, br"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Accept-Language: en-US,en;q=0.9"
2023/10/29 18:08:59 [debug] 29#29: *6 http header done
2023/10/29 18:08:59 [debug] 29#29: *6 event timer del: 19: 130773327
2023/10/29 18:08:59 [debug] 29#29: *6 generic phase: 0
2023/10/29 18:08:59 [debug] 29#29: *6 rewrite phase: 1
2023/10/29 18:08:59 [debug] 29#29: *6 test location: "/"
2023/10/29 18:08:59 [debug] 29#29: *6 using configuration "/"
2023/10/29 18:08:59 [debug] 29#29: *6 http cl:-1 max:1048576
2023/10/29 18:08:59 [debug] 29#29: *6 rewrite phase: 3
2023/10/29 18:08:59 [debug] 29#29: *6 http script var
2023/10/29 18:08:59 [debug] 29#29: *6 http script var: "GET"
2023/10/29 18:08:59 [debug] 29#29: *6 http script regex: "(GET|POST)"
2023/10/29 18:08:59 [notice] 29#29: *6 "(GET|POST)" matches "GET", client: 192.168.0.1, server: _, request: "GET /.well-known/mercure?topic=test HTTP/1.1", host: "localhost:4000"
2023/10/29 18:08:59 [debug] 29#29: *6 http script if
2023/10/29 18:08:59 [debug] 29#29: *6 http script var
2023/10/29 18:08:59 [debug] 29#29: *6 http script var: "GET"
2023/10/29 18:08:59 [debug] 29#29: *6 http script value: "OPTIONS"
2023/10/29 18:08:59 [debug] 29#29: *6 http script equal
2023/10/29 18:08:59 [debug] 29#29: *6 http script equal: no
2023/10/29 18:08:59 [debug] 29#29: *6 http script if
2023/10/29 18:08:59 [debug] 29#29: *6 http script if: false
2023/10/29 18:08:59 [debug] 29#29: *6 post rewrite phase: 4
2023/10/29 18:08:59 [debug] 29#29: *6 generic phase: 5
2023/10/29 18:08:59 [debug] 29#29: *6 generic phase: 6
2023/10/29 18:08:59 [debug] 29#29: *6 generic phase: 7
2023/10/29 18:08:59 [debug] 29#29: *6 access phase: 8
2023/10/29 18:08:59 [debug] 29#29: *6 access phase: 9
2023/10/29 18:08:59 [debug] 29#29: *6 access phase: 10
2023/10/29 18:08:59 [debug] 29#29: *6 post access phase: 11
2023/10/29 18:08:59 [debug] 29#29: *6 generic phase: 12
2023/10/29 18:08:59 [debug] 29#29: *6 generic phase: 13
2023/10/29 18:08:59 [debug] 29#29: *6 http init upstream, client timer: 0
2023/10/29 18:08:59 [debug] 29#29: *6 epoll add event: fd:19 op:3 ev:80002005
2023/10/29 18:08:59 [debug] 29#29: *6 http script copy: "X-Forwarded-For"
2023/10/29 18:08:59 [debug] 29#29: *6 http script var: "192.168.0.1"
2023/10/29 18:08:59 [debug] 29#29: *6 http script copy: "X-Forwarded-Host"
2023/10/29 18:08:59 [debug] 29#29: *6 http script var: "localhost"
2023/10/29 18:08:59 [debug] 29#29: *6 http script copy: "X-Forwarded-Proto"
2023/10/29 18:08:59 [debug] 29#29: *6 http script var: "http"
2023/10/29 18:08:59 [debug] 29#29: *6 http script copy: "Host"
2023/10/29 18:08:59 [debug] 29#29: *6 http script var: "freddie"
2023/10/29 18:08:59 [debug] 29#29: *6 http script copy: ""
2023/10/29 18:08:59 [debug] 29#29: *6 http script copy: ""
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Cache-Control: max-age=0"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "sec-ch-ua: "Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99""
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "sec-ch-ua-mobile: ?0"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "sec-ch-ua-platform: "Linux""
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Upgrade-Insecure-Requests: 1"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Sec-Fetch-Site: none"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Sec-Fetch-Mode: navigate"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Sec-Fetch-User: ?1"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Sec-Fetch-Dest: document"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Accept-Encoding: gzip, deflate, br"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Accept-Language: en-US,en;q=0.9"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header:
"GET /.well-known/mercure?topic=test HTTP/1.1
X-Forwarded-For: 192.168.0.1
X-Forwarded-Host: localhost
X-Forwarded-Proto: http
Host: freddie
Cache-Control: max-age=0
sec-ch-ua: "Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Linux"
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Sec-Fetch-Site: none
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9

"
2023/10/29 18:08:59 [debug] 29#29: *6 http cleanup add: 000055BC9DBCB850
2023/10/29 18:08:59 [debug] 29#29: *6 get rr peer, try: 1
2023/10/29 18:08:59 [debug] 29#29: *6 stream socket 20
2023/10/29 18:08:59 [debug] 29#29: *6 epoll add connection: fd:20 ev:80002005
2023/10/29 18:08:59 [debug] 29#29: *6 connect to 127.0.0.1:4001, fd:20 #7
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream connect: -2
2023/10/29 18:08:59 [debug] 29#29: *6 posix_memalign: 000055BC9DB54E60:128 @16
2023/10/29 18:08:59 [debug] 29#29: *6 event timer add: 20: 60000:130773327
2023/10/29 18:08:59 [debug] 29#29: *6 http finalize request: -4, "/.well-known/mercure?topic=test" a:1, c:2
2023/10/29 18:08:59 [debug] 29#29: *6 http request count:2 blk:0
2023/10/29 18:08:59 [debug] 29#29: *6 http run request: "/.well-known/mercure?topic=test"
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream check client, write event:1, "/.well-known/mercure"
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream request: "/.well-known/mercure?topic=test"
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream send request handler
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream send request
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream send request body
2023/10/29 18:08:59 [debug] 29#29: *6 chain writer buf fl:1 s:755
2023/10/29 18:08:59 [debug] 29#29: *6 chain writer in: 000055BC9DBB9818
2023/10/29 18:08:59 [debug] 29#29: *6 writev: 755 of 755
2023/10/29 18:08:59 [debug] 29#29: *6 chain writer out: 0000000000000000
2023/10/29 18:08:59 [debug] 29#29: *6 event timer del: 20: 130773327
2023/10/29 18:08:59 [debug] 29#29: *6 event timer add: 20: 86400000:217113327
2023/10/29 18:08:59 [debug] 29#29: accept on 0.0.0.0:4000, ready: 0
2023/10/29 18:08:59 [debug] 29#29: posix_memalign: 000055BC9DBA0140:512 @16
2023/10/29 18:08:59 [debug] 29#29: *8 accept: 192.168.0.1:57466 fd:21
2023/10/29 18:08:59 [debug] 29#29: *8 event timer add: 21: 60000:130773327
2023/10/29 18:08:59 [debug] 29#29: *8 reusable connection: 1
2023/10/29 18:08:59 [debug] 29#29: *8 epoll add event: fd:21 op:1 ev:80002001
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream request: "/.well-known/mercure?topic=test"
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream process header
2023/10/29 18:08:59 [debug] 29#29: *6 malloc: 000055BC9DB72CB0:4096
2023/10/29 18:08:59 [debug] 29#29: *6 posix_memalign: 000055BC9DB73CC0:4096 @16
2023/10/29 18:08:59 [debug] 29#29: *6 recv: eof:0, avail:-1
2023/10/29 18:08:59 [debug] 29#29: *6 recv: fd:20 137 of 4096
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy status 200 "200 OK"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Content-Type: text/event-stream"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Server: ReactPHP/1"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Date: Sun, 29 Oct 2023 18:08:59 GMT"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Transfer-Encoding: chunked"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header done
2023/10/29 18:08:59 [debug] 29#29: *6 xslt filter header
2023/10/29 18:08:59 [debug] 29#29: *6 HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Sun, 29 Oct 2023 18:08:59 GMT
Content-Type: text/event-stream
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Origin: *

2023/10/29 18:08:59 [debug] 29#29: *6 write new buf t:1 f:0 000055BC9DB73E08, pos 000055BC9DB73E08, size: 204 file: 0, size: 0
2023/10/29 18:08:59 [debug] 29#29: *6 http write filter: l:0 f:0 s:204
2023/10/29 18:08:59 [debug] 29#29: *6 http cacheable: 0
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy filter init s:200 h:0 c:1 l:-1
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream process upstream
2023/10/29 18:08:59 [debug] 29#29: *6 pipe read upstream: 0
2023/10/29 18:08:59 [debug] 29#29: *6 pipe preread: 0
2023/10/29 18:08:59 [debug] 29#29: *6 pipe buf free s:0 t:1 f:0 000055BC9DB72CB0, pos 000055BC9DB72D39, size: 0 file: 0, size: 0
2023/10/29 18:08:59 [debug] 29#29: *6 pipe length: 3
2023/10/29 18:08:59 [debug] 29#29: *6 event timer: 20, old: 217113327, new: 217113327
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream request: "/.well-known/mercure?topic=test"
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream dummy handler

Can you help me to solve this error?

Thank you.
Igor.

RedisTransport on close

Using the RedisTransport Pub/Sub, if there is an error in Redis resulting in a connection closure, there isn't a logic in place to perform a reconnection and potentially recycle the subscribe. I think we are missing a listener for $this->subscriber->on('close') in the RedisTransport's init(), and to handle this issue. We noticed this in practice, in our production environment. Whenever Redis crashes or reboots, Mercure becomes inconsistent and non-functional.

Cannot publish updates to mercure hub.

I installed freddie mercure hub. During installation i had encountered some namespace mismatch issue, i solved it. When i run the hub. All i get is 404 Page not found error. I can't find any logs. How can i successfully run this project?
Screenshot 2023-05-15 at 10 39 48

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.