Issue on multiple connections with proxy Apache

49 views Asked by At

In my application, I have a local Mercure hub connected via proxy to my Apache server:

Here's the proxy on my Apache server:

ProxyPass "/hub/" http://localhost:3000/
ProxyPassReverse "/hub/" http://localhost:3000/

The connection between the client and the hub works very well when querying my Apache server.

Here's the client-side code connecting to the hub:

const eventSource = new EventSourcePolyfill(url, {
headers: {
Authorization: token,
},
});

The 'url' is the link to the Mercure topic.

I can open multiple tabs; each tab establishes a connection to the hub by connecting to the Apache proxy which redirects to the Mercure hub from the same client. However, when I try to refresh one of the tabs in the browser, it goes into a loop until I close one of the other tabs.

loop-apache

Here's my Mercure config:

{
{$GLOBAL_OPTIONS}
auto_https off
}

{$SERVER_NAME:http://localhost:3000}

log {
level WARN
format filter {
wrap console
fields {
uri query {
replace authorization REDACTED
}
}
}
}

{$EXTRA_DIRECTIVES}

route {
encode zstd gzip
mercure {
    # Transport to use (default to Bolt)
    transport_url {$MERCURE_TRANSPORT_URL:bolt://mercure.db}
    # Publisher JWT key
    publisher_jwt {env.MERCURE_PUBLISHER_JWT_KEY} {env.MERCURE_PUBLISHER_JWT_ALG}
    # Subscriber JWT key
    subscriber_jwt {env.MERCURE_SUBSCRIBER_JWT_KEY} {env.MERCURE_SUBSCRIBER_JWT_ALG}
    # Extra directives
    {$MERCURE_EXTRA_DIRECTIVES}
    publish_origins *
    ui
    anonymous
    subscriptions
    cors_origins https://productions.ats-dev.fr
    {$MERCURE_EXTRA_DIRECTIVES}
}

Locally, I don't have this problem, and the only difference is the use of an Apache proxy on the remote server and the addition of the 'auto_https off' directive in the Mercure configuration to prevent it from interfering with port 80 on my server.

I have no connections limitation on my Apache Server.

It just looks like Apache waiting for an event (which is trigger when a tab is closed) and not send any response until this event isn't call.

0

There are 0 answers