Giter Site home page Giter Site logo

dunglas / mercure Goto Github PK

View Code? Open in Web Editor NEW
3.7K 61.0 277.0 8.09 MB

🪽 An open, easy, fast, reliable and battery-efficient solution for real-time communications

Home Page: https://mercure.rocks

License: GNU Affero General Public License v3.0

Go 85.91% HTML 4.53% CSS 0.07% JavaScript 3.09% Dockerfile 0.07% Scala 1.91% Shell 0.73% Smarty 0.66% TypeScript 3.03%
api web-api server-sent-events subscriptions golang hypermedia graphql push streaming-api mercure

mercure's Introduction

Mercure: Real-time Made Easy

Protocol and Reference Implementation

Mercure is a protocol for pushing data updates to web browsers and other HTTP clients in a convenient, fast, reliable, and battery-efficient way. It is especially useful to publish async and real-time updates of resources served through web APIs, to reactive web and mobile apps.

Awesome Artifact HUB PkgGoDev CI Coverage Status Go Report Card

Subscriptions Schema

The protocol is maintained in this repository and is also available as an Internet-Draft.

A reference, production-grade, implementation of a Mercure hub (the server) is also available in this repository. It's free software (AGPL) written in Go. It is provided along with a library that can be used in any Go application to implement the Mercure protocol directly (without a hub) and an official Docker image.

In addition, a managed and high-scalability version of the Mercure.rocks hub is available on Mercure.rocks.

Contributing

See CONTRIBUTING.md.

License and Copyright

See license information.

Credits

Created by Kévin Dunglas. Graphic design by Laury Sorriaux. Sponsored by Les-Tilleuls.coop.

mercure's People

Contributors

alexislefebvre avatar azjezz avatar cassiobotaro avatar castrocrea avatar chalasr avatar cklm avatar dependabot[bot] avatar divine avatar dunglas avatar eroluysal avatar fabious avatar jamuelstarkey avatar jdecool avatar jderusse avatar jfcoz avatar kevburnsjr avatar maxhelias avatar meyerbaptiste avatar remy-luciani avatar richard87 avatar rneuter avatar robertodormepoco avatar sagikazarmark avatar slim avatar soyuka avatar sroze avatar superhaggis avatar tamasszigeti avatar te4g avatar vitorluis 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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

mercure's Issues

How to send an event to a specific user?

an element may be missing or I'm doing it wrong:
I have a topic: ?topic=notifications
I have a token creation with these parameters:

{
  "mercure": {
    "subscribe": [
      "ff9c12f4-35f5-4b0d-b005-048fa029c285"
    ]
  }
}

I have a command that will give me notifications to this user, so my token looks like this:

{
  "mercure": {
    "publish": [
      "ff9c12f4-35f5-4b0d-b005-048fa029c285"
    ]
  }
}

out even if I put another target my user still receives the notifications.

How can I make sure that several users with topic notification can have this notification and not the neighbor's?

Get Old Messages

As a subscriber, how would I craft a subscription to get the old event messages from the hub? Is it a matter of setting a time in the GET request?

How to revoke subscribers?

Hi,

I have a question regarding targeting updates. Let's say I have an Account with many Members and I want to publish an update of the Account info to its Members on an "accounts" topic. At the same time I don't want this update to be received by other subscribers who are not Members.

I thought that Member ID should be target and when the Member is removed from the Account, I remove the Member ID from targets of the update. But what if I have a large Account, with, let's say, thousands of Members? A JWT token containing all Member IDs would be huge and the update would sooner or later hit performance limits...

In the protocol specs you mention a "group of subscribers", which might be a solution regarding the token size, but how do I revoke a subscriber from such group? Is it even possible?

Serialize server-sent events

Hello, we have a project on Symphony 4 + Api platform. We use Mercure and it works nice but there is one question about serialize " server-sent events". Why when i am getting server-event and if my Json contains a one nested element then this element is an array of one object, but if i am getting the same Json from Mercure(server-event) this element is just an object. I need to get an array of one object. How i can do it?

Offer more debug on infamous 401

Hey,

after sorting out the CORS issue with anonymous request, I'm trying to use authorized ones, but the 401 is driving me nuts. I'm running on a my.test domain and mercure is running on my.test:3000. It somehow seems that the browser doesn't want to send the cookie along with the EventSource. At least it cannot be found in the Request Headers section in the dev tools.

The cookie is created through a Symfony action:

Set-Cookie: mercureAuthorization=...; path=/hub; httponly; samesite=strict

and I can verify it on jwt.io.

  1. I tried to use withCredentials: true on the EventSource, but than the browser complains that * is not allowed in the CORS_ALLOWED_ORIGINS.

  2. I then tried to use CORS_ALLOWED_ORIGINS=http://localhost, but then Chrome complains that "No 'Access-Control-Allow-Origin' header is present" and the network tab shows no response headers at all.

  3. I then set CORS_ALLOWED_ORIGINS=http://my.test. This way I get a proper Access-Control-Allow-Origin: http://my.test response header, but along with the 401 and no cookie in the request headers.

  4. If I access http://my.test:3000/hub?topic=... directly the cookie is properly sent.

So... what setup should? Should the same-site cookie be send with EventSource w/o credentials? Should it work with CORS_ALLOWED_ORIGINS=*?

And pleeease add a reason for the 401 when running with DEBUG=1. There are so many different things which can go wrong and mercure has to know what it doesn't like.

Cheers
Matthias

Getting a 401 Unauthorized

I'm trying to connect to the Mercure hub.
I have this code to subscribe (don't worry it's a test JWT):

var token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXJjdXJlIjp7InN1YnNjcmliZSI6WyJhc2QiXX19.pdpWxTWkHqxT8v-hMJ6pl7dWD5PomhFWdx6yhQiUp0c";

document.cookie = "mercureAuthorization="+token+"; path=/hub; expires=Thu, 18 Dec 2020 12:00:00 UTC;";

const es = new EventSource('http://localhost:3000/hub?topic=' + encodeURIComponent('asd'), { withCredentials: true });
es.onmessage = e => {
    // Will be called every time an update is published by the server
    console.log(JSON.parse(e.data));
}

And it straight up gives me a 401.

This is my Mercure start command:

JWT_KEY='aVerySecretKey' ADDR='localhost:3000' CORS_ALLOWED_ORIGINS=http://127.0.0.1:8000 ~/Applications/mercure

Im trying this on a Mac.

Room support

Hi, Dunglas!
Mercure is great idea and project, but it really needs in rooms feature.
For example, we have SaaS platform with isolated owners, and we want to to stream realtime updates only to specific owners, not to all users. In current implementation we can't achieve that behavior (or I missed something)
Do you have any plans or ideas regarding that functionality?

Immutable infrastructure; how to host mercure on them ?

Hello,

I just asked a cloud provider if they have any plans to offer Mercure on their PaaS. They said that they cannot because they have an immutable architecture, each time we deploy, it's on a new container so data are not kept.

Reference tweet: https://twitter.com/Soulou/status/1102933346215231488

They pointed out issues discussed in #10, but we're not interested in redundancy, just host mercure on an immutable infrastructure :)

Is this possible ? Thanks

Running Mercure on a server that already serves sites over SSL

Hello,
I redesigned one of my systems to use mercure without realizing that, the binary will fail binding to port 443 because apache2 is already using it. Does any of you know for a workaround for that? Is my only option to spawn another server for that?

Thanks in advance and kudos for the great software, I'm really enjoying it so far.

Routes for API Platform and Mercure

Hello,
i got mercure to work with my api platform.
Its all fine but I cant subscribe to the routes, because i dont know them.

I have the following entity: "Customer"

If i create/change or delete something it publishes the changes like it should.

I tried the following routes:
localhost:3000/api/customers
localhost:3000/api/customers.jsonId

also i tried:
localhost:3000/api/customers/1
localhost:3000/api/customers/1.jsonId

and some useless links that I tried because i was frustrated.

What would be the URL to subscribe?

sorry for my bad english 💃

Exited (137)

Hello.
I am having trouble getting docker image to run: exits with code 137 (and no message) after a few seconds. Knowing (almost for sure: no such output from journalctl, and inspecting container returns "OOMKilled": false) that it is not a matter of memory, do you have any idea what I missed?..

My setup is as follow:

  • a mercure.env file with the following:
    CERT_FILE=/data/cert.pem
    KEY_FILE=/data/privkey.pem
    DB_PATH=/data/updates.db
    DEBUG=0
    DEMO=0
    PUBLISHER_JWT_KEY=<secret>
    SUBSCRIBER_JWT_KEY=<other-secret>
  • a data directory used to store custom cert files (multi-domains certificate from letsencrypt) and DB
  • the launch command:
    docker run --env-file mercure.env --mount type=bind,source=${PWD}/data,target=/data --name mercure -p 9443:443 dunglas/mercure

As a side note, changing to DEBUG=1 does not bring more information.

Missing Access-Control-Allow-Origin header

I'm trying to access the hub from a subdomain in a web browser using EventSource(url, {withCredentials: true}). First I got an error saying wildcard * can not be used when include credentials mode is enabled so I changed the mercure server flag 'CORS_ALLOWED_ORIGINS' and set my domain instead "*". Now when I send an update from the hub to the client I'm getting "No 'Access-Control-Allow-Origin' header is present on the requested resource"

I will not change the domain name of cookie, how to solve it

vue-cli3
vue
My local address:http://localhost:8080/#/chat/index
Server address:https://mercure.a031.com/
I use EventSource

let jwt='***jwt_key*';
const u = new URL(hubUrl)
    topicList.forEach(topic => u.searchParams.append('topic', topic))
    u.searchParams.append('Last-Event-ID', 2)
    var eventSourceInitDict = {
      withCredentials: false,
      headers: {
        Authorization: 'Bearer ' + jwt,
        Cookie: 'mercureAuthorization=' + jwt,
        'Access-Control-Allow-Origin': '*'
      }
    }
    eventSource = new EventSource(u, eventSourceInitDict)
    eventSource.onmessage = function(e) {
      console.log(e)
    }
    eventSource.onerror = error

image

Unauthorized

JWT_KEY='pasword' ADDR=':4000' CORS_ALLOWED_ORIGINS='*' LOG_FORMAT='json' DEMO=1  ./mercure

I will not change the domain name of cookie, how to solve it

FATA[0000] invalid argument

Hi,

I'm trying to start mercure inside a virtualbox running Centos 7.
Using the example from Readme:

JWT_KEY='myJWTKey' ADDR=':3000' DEMO=1 ALLOW_ANONYMOUS=1 CORS_ALLOWED_ORIGINS=* PUBLISH_ALLOWED_ORIGINS='http://localhost:3000' ./mercure

results in
FATA[0000] invalid argument

I'm using the latest release of mercure 0.5.0 from the release page.

Is there some kind of verbose mode or any log files?
Are there any requirements that needs to be additionally installed on the machine?

Any hints on this would be appreciated.

thanx!

Updates.db Steadily Growing

Hello,
I have noticed that the updates.db file continues to grow in size after publishing messages. I've had the server running for about a week and now the updates.db file is a little greater than 504 MB. Am I to assume that if I set an expiration time on the JWT, the message will remove from the updates.db file?

Thank you in advance.

How to publish to a group of non-specific targets ?

This is more a question about the protocol itself than about this implementation.

Here's a use case I ran into :

A specific user (using a Browser) subscribes to this topic : http://example.com/books/{id}.
I want this user to get notifications about all books.

Question :

What do I have to store inside the claims of his JWT to say they should receive notifications about all the books ? My (theoretical) workaround is this :

{
  "mercure": {
    "subscribe": [
      "http://example.com/books/*"
    ]
  }
}

Then I dispatch an event to the topic http://example.com/books/ID_OF_BOOK and these targets :

  • http://example.com/books/* : so this particular user can get the notification
  • http://example.com/books/ID_OF_BOOK : so the other users can also receive the notification, as their allowed targets are : ["http://example.com/books/ID_OF_BOOK"].

Maybe should I find an other way and use targets specifying the users instead of specifying the books ?

Connection events

Is it possible to trigger events and send them to my application server to know if a user is connected/disconnected?

Golang client

Is there a golang client ?

Want to use this for IOT and also non web GUI like flutter.

The system with hateos looks like a genius solution to a tough long standing problem. Congrats !!

How to set a custom CERT file and key properly ?

When I specified the CERT_FILE and CERT_KEY, mercure throw an error :
level=error msg="open : no such file or directory"

Here's my config docker-compose.yml

mercure:
    image: dunglas/mercure
    environment:
      - CERT_FILE=/cert/cert.crt
      - CERT_KEY=/cert/cert.key
      - JWT_KEY=MyJwtSecret
      - ALLOW_ANONYMOUS=1
      - PUBLISH_ALLOWED_ORIGINS=*
      - CORS_ALLOWED_ORIGINS=*
    expose:
      - 443
    volumes:
      - ./docker/mercure/cert.crt:/cert/cert.crt
      - ./docker/mercure/cert.key:/cert/cert.key

Do you have an idea of what is happening ?

How to authenticate subscriber?

Hi,
could you please clarify how subscribers can authenticate themselves against hub in case the hub runs on a different domain?

I have a frontend app on one domain with REST API on another domain and a mercure hub on a third domain. At https://demo.mercure.rocks/ you have two options - mercureAuthorization using a cookie, or HTTP header. In my case I cannot send HTTP header to authenticate with EventSource (even you alert in your demo that it is not possible). But how could I make the hub to set the mercureAuthorization cookie for me? The discover endpoint may be on the API, but it is on a different domain.

Maybe I am doing something wrong, thanks for any help!

Can we subscribe all topics allowed by the JWT?

Hi,

Is there a way to subscribe to all topics? (within the limitation of what the JWT allows, of course)
Essentially, I'd like the topic parameter to be optional or being able to use the wildcard when listening:

let url = new URL('http://localhost/hub');
url.searchParams.append('topic', '*');
let eventSource = new EventSource(url.toString(), {withCredentials: true});

Right now, my page load generates the mercureAuthorization JWT with a few topics (this is how I restrict the clients), but I looks like I also need to append all the topics I have listed in my JWT to the Event source URL, which feels like duplicating.

JWT Key > 401

the description says:

{
  "mercure": {
    "subscribe": ["list of authorized targets, * for all, omit for public only"],
    "publish": ["list of authorized targets, * for all, omit to not allow to publish"]
  }
}

so i created a jwt key with all permissions out of it:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXJjdXJlIjp7InN1YnNjcmliZSI6WyIqIl0sInB1Ymxpc2giOlsiKiJdfX0.1MdY6fynJEDJTebHDM1WSfqH4vPXufrffN8hBnUiziQ

but its not working, its exactly the same then the demo jwt, except its "*"

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXJjdXJlIjp7InN1YnNjcmliZSI6WyJmb28iLCJiYXIiXSwicHVibGlzaCI6WyJmb28iXX19.LRLvirgONK13JgacQ_VbcjySbVhkSmHy3IznH3tA9PM

i everytime get 401
my .env of mercure:

ACME_CERT_DIR=
ACME_HOSTS=
ADDR=:3000
ALLOW_ANONYMOUS=1
#CERT_FILE=fixtures/tls/server.crt
#KEY_FILE=fixtures/tls/server.key
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:8000,*
DB_PATH=
DEBUG=1
DEMO=
JWT_KEY=!UnsecureChangeMe!
LOG_FORMAT=JSON
PUBLISH_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:8000,*
PUBLISHER_JWT_KEY=
SUBSCRIBER_JWT_KEY=
HEARTBEAT_INTERVAL=10s
READ_TIMEOUT=0s
WRITE_TIMEOUT=0s

Ability for publisher to list subscribers

Hi everyone, can a publisher list the subscribers for a giving topic? This could be helpful to filter response payload and forward "only interest thing" to subscribers.

Need to run as root?

The README says production mode requires running mecure as root. What is this necessary for? I would like to run it with less privileges if possible.

Out of memory error when requiring mercure

I tried to install mercure using composer. I get this error:

$ composer require symfony/mercure
PHP Warning: Module 'openssl' already loaded in Unknown on line 0

Warning: Module 'openssl' already loaded in Unknown on line 0
Using version ^0.1.0 for symfony/mercure
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

VirtualAlloc() failed: [0x00000008] Not enough memory resources are available to process this command.

VirtualFree() failed: [0x000001e7] Attempt to access invalid address.

VirtualAlloc() failed: [0x00000008] Not enough memory resources are available to process this command.

VirtualFree() failed: [0x000001e7] Attempt to access invalid address.

PHP Fatal error: Out of memory (allocated 1570766848) (tried to allocate 4096 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/Solver.php on line 223

Fatal error: Out of memory (allocated 1570766848) (tried to allocate 4096 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/Solver.php on line 223

Add warning about CORS_ALLOWED_ORIGINS

Hi,

it'd be great if you could add a warning about CORS_ALLOWED_ORIGINS. It took my some time and trial-and-error to come to the final conlusion that I have to set CORS_ALLOWED_ORIGIN=* on my localhost to get this started.

I followed the Symfony doc and could only figure this our switching from Firefox to Chrome. I also proposed the change for the doc: symfony/symfony-docs#11116

Cheers
Matthias

[Question] pattern matching

When we subscribe with pattern matching like :
const url = new URL('https://example.com/hub'); url.searchParams.append('topic','https://example.com/books/{id}');
Can we have a way to get somewhere the corresponding value of {id} ?

If I push on https://example.com/books/56
I want to get id => 56
Thanks :)

installing hub on windows

Hi,

thanks for your work, it seems really great and to be very usefull.

I just need to make it work...

I'm trying to test it in local env on a symfony 3.4 app. I'm working on windows 10 with wamp64.

I get some trouble to run the mercure.exe and i don't find any example (evrything is just on linux), I've donwloaded the V0.4.1 x86_64 for windows, unzipped, put it on my wamp64/www folder and trying to run the exe like this :
start mercure JWT_KEY='aVerySecretKey' ADDR='localhost:3000' ALLOW_ANONYMOUS=1 CORS_ALLOWED_ORIGINS=*

I have something like a window popping up but no message that the application is running and when I'm going to localhost:3000 no mercure welcome page

I'm missing something ??

Excuse if my question is stupid but i'm pretty beginer in this world :)

Intermediate certificate

Hi,

On my production environment I have an intermediate certificate. So in total I have 3 files:

  • the certificate of my domain
  • the private key
  • the intermediate certificate

In the configuration I can only set the first 2, but not the last one. So I get this kind of error when I try to publish something to Mercure:

http: TLS handshake error from 217.70.191.82:45486: remote error: tls: unknown certificate authority

Could you please help me?

Allow Hub to scale

The current implementations of History interface does not allows the "hub" component to scale: The events are stored in local database, that could not be shared across several instances of Hub.

Moreover, the "FindFor" method scan sequentially the database looking for the next items. This implementation would have significant performance impact on a highly used hub with millions of items.

I think that scaling is requirements for the adoption of the project/protocol, it would allows to:

  • handle a very large number of concurrent clients
  • handle a high throughput of message (or large messages)
  • provides edge hub located close to the client and reduce network latency

To solve both issues I suggest few changes in the implementation and protocol specifications:

The uses of a shared Streaming Database (ie. Kafka, AWS Kinesis, Redis 5 stream, ...) to store events would allow running concurrently several instances of Hub.

As several instances of Hub are running, the hub have to also broadcast messages published by other Hub in the cluster. The streaming database (and the MissedEvent feature) could become the source of trust.

With a schema, this is what I'm thinking

# current
                  /+------+\
                 +          +
                 |\+------+/|
                 |          |
                 | Database |
          +------>          <-----+
          |      +----------+     | (init and re-connect)
          |                       |
+---------+-+      +------+     +-+-----------+
|           |      |      |     |             |
| Publisher |      | chan |     |  Subscriber |
|           +------>      <-----+             |
+-----------+      +------+     +-------------+


# proposal
+-----------+                   +-------------+
|           |    /---------\    |             |
| Publisher |   +           +   |  Subscriber |
|           +--->\---------/<---+             |
+-----------+   |           |   +-------------+
+-----------+   | Streaming |   +-------------+
|           |   | Database  |   |             |
| Publisher +--->           <---+  Subscriber |
|           |   +-----------+   |             |
+-----------+                   +-------------+

To enjoy the benefits of the streaming database, the "last-event-id" should not be generated by the producer (because most of the time such database does not provides primitives to search items, they provide tools to create a cursor at some point in the database (named sequence number) and then traversing the database from that point).
In my opinion, the hub should return the sequence number generated by the streaming database, and the server should take that sequence as the "last-event-id".

If we want to keep the current spec and let the server generating that "last-event-id", the Hub would have to use KeyValue database to convert the "last-event-id" into database sequence number.

Cannot sub to mercure through https with EventSource

Hi Mercure Team,

I push this issue even if i know it has small chance to be a real issue, sorry about that. But if you can give me a clue i will be happy.

My problem is that i can subscribe to my mercure server through HTTPS using cURL and i can see updates.

But when i use eventSource it doesn't work, the eventSource stay in readyState 0, connecting...

Is there any chance you might guess the reason ?

Anyway thanks a lot for your time,
Thomas.

use Mercure on AWS

Hello,

When I put in production Mercure on AWS and launch it with the command:

JWT_KEY='myJWTKey' ADDR='3000' ACME_HOSTS='my_website.com' ./mercure

And i go to https://my_website.com:3000/hub this page runs to infinity!

someone have idea?

Thanks
Sidi

Unable to get it working locally

Hi. Thank you for the work. Looks awesome. I wish you best luck with this project.
I had a problem to get it working but now, after several hours I got it working. Not sure what exactly was the problem. Probably something with exclamation mark in JWT key :-).

BTW I was also setting the whole token as JWT_KEY for a while until I realised it does not make any sense :-). It was really dumb but i propose to rename the variable to JWT_SECRET to make it clearer.

Problem encountered on raspbian raspberry pi 3

Hi, I recount a problem on my raspberry pi raspbian: time = "2019-01-15T14: 45: 07Z" level = error msg = "listen tcp: address tcp / 5000 ': unknown port" when launching the application with systemd when I launch it alone the console does not display anything. I would like to know how to deal with this problem. Thank you for this wonderful job and really sorry for my english.

Cannot make it works locally :/ ?

Hi everyone,

I am sorry to open an issue but i have tried for a couple days by now to make it work locally, but i did not succeed :/

First of all i have downloaded a binary and start it with :

JWT_KEY='myJwtKey' ADDR=':3000' DEMO=1 ALLOW_ANONYMOUS=1 PUBLISH_ALLOWED_ORIGINS='http://localhost:3000' ./mercure

It works and i can access on localhost:3000 GREAT :)

Then with Postman i subscribe with this call :

GET http://localhost:3000/hub?topic=http://localhost:3000/demo/books/1.jsonld
I don't put a token on subscribe because if i do it, i will get an Unauthorized Error

Without token i can see on the console output :
INFO[0000] Mercure started protocol=http ::1 - - [20/Feb/2019:19:10:16 +0100] "GET /hub?topic=http://localhost:3000/demo/books/1.jsonld HTTP/1.1" 401 37 "" "PostmanRuntime/7.6.0" INFO[0047] New subscriber remote_addr="[::1]:57706"

And then i try to push some modifications with this call :

POST http://localhost:3000/hub
With this body :
topic: http://localhost:3000/demo/books/1.jsonld
data: { foo: 'updated value' }

With these headers
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXJjdXJlIjp7InB1Ymxpc2giOltdfX0.473isprbLWLjXmAaVZj6FIVkCdjn37SQpGjzWws-xa0

This token has this structure :
{
"mercure": {
"publish": []
}
}

And i got an Unauthorized Error as well :/

What am i missing ?

Thanks in advance for the help,
I appreciate your work this is why i try to implement it at work
Thanks,
Thomas.

Websub protocol

There is a golang websub implementation I saw. Gotta find it. This is designed for server to server.

Am thinking about also supporting websub on top of Mercure. It would be a different entry point but can use all the event tracking still to provide a architecture for microservices.

What do you think ?

Private and public topic

Bonjour Kévin,

Je commence par te remercier pour ce super projet qui me simplifie énormément la vie en remplacement des WebSockets.

Je me permets de t'écrire car la documentation me semble floue (ou alors je rate quelque chose) sur la notion de mises à jour privées. Je comprends que cela se joue via la notion de "targets" que l'on spécifie au niveau des pushs mais comment spécifier au niveau du token des subscribers quels sont les targets auxquels ils ont droit ?

Merci pour tes éclaircissements ;-)

Binary (or how to build)

Apologies, I am editing/changing the issue.
I've cloned the repo on my mac (rather than debian). I then ran:

go get github.com/dunglas/mercure/hub
go get github.com/joho/godotenv/autoload
go get github.com/joonix/log

to install the dependencies. Now when I do a go run main.go I get the following:

# github.com/dunglas/mercure/hub
../github.com/dunglas/mercure/hub/demo.go:40:11: unknown field 'SameSite' in struct literal of type http.Cookie

Any ideas?

[QUESTION] Dockerfile ports

Hi everyone,

Small question about the ports used by the Dockerfile, it is possible to change the default 80 443 value to something like 8080 443? 🤔

I've tried to do it via env variables but it doesn't seem to work :/

Thanks again for the feedback and have a great day :)

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.