dunglas / mercure

🪽 An open, easy, fast, reliable and battery-efficient solution for real-time communications
https://mercure.rocks
GNU Affero General Public License v3.0
3.97k stars 296 forks source link

Cannot sub to mercure through https with EventSource #98

Closed thomasmoreaumaster closed 5 years ago

thomasmoreaumaster commented 5 years ago

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.

dunglas commented 5 years ago

Did you checked CORS settings? Do you have anything in the console that can help? Otherwise you'll have to use a tool like Wireshark to debug at a lower level.

thomasmoreaumaster commented 5 years ago

Yes i put a variable to my compute engine CORS_ALLOWED_ORIGINS=* so i can test my developments locally.

/docker# vim docker-compose.yml var env :

I got nothing in my console, neither in my network tool.

i just can console.log the eventSource

EventSource {url: "https://mercure.decathlon.com/hub?topic=http://127.0.0.1/api/v1/stores/350/messages", withCredentials: false, readyState: 0, onopen: null, onmessage: null, …} onerror: null onmessage: ƒ (e) onopen: null readyState: 0 url: "https://mercure.decathlon.com/hub?topic=http://127.0.0.1/api/v1/stores/350/messages" withCredentials: false __proto__: EventSource

And if i run my mercure server locally everything works fine.

Ok Let's do it with WireShark lol :)

Thanks a lot for your time :) Thomas.

thomasmoreaumaster commented 5 years ago

Hi @dunglas,

I used wireshark to try to understand why i can subscribe with cURL and not with my Angular eventSource.

I look for differences between 2 wireshark records and i found one difference : cURL is using http-over-tls protocol on SSL part while Angular eventSource is using http2.

Do you think it might be the cause ? do you suggest me to look somewhere else ? But where :) ?

Thanks for your time, Thomas.

Screenshot from 2019-06-09 12-49-23 Screenshot from 2019-06-09 12-49-02

thomasmoreaumaster commented 5 years ago

hi @dunglas,

Problem solved i use nginx with http1 & 2 and now the problem is solved.

Thanks again for your time, Thomas.