fanout / django-eventstream

Server-Sent Events for Django
MIT License
664 stars 88 forks source link

Strange behaviour #32

Open tboulogne opened 5 years ago

tboulogne commented 5 years ago

Hello,

I follow https://channels.readthedocs.io/en/latest/deploying.html#example-setups for deploying with event stream with channels.

I got get a strange behavior if numprocs > 1. Only few messages (around one on three) are sent. If i set numprocs to 1, i get all messages.

Any idea on what happend ?

Thanks for help.

regards

OS: ubuntu 18.04 supervisor: 3.3.1 channels: 2.1.5 event stream: latest

jkarneges commented 5 years ago

Hi,

The processes don't talk to each other, so when a message is sent it is only pushed to clients connected to the same process. To support multiple processes, you'll need to delegate connection management to a GRIP proxy. See multiple instances and scaling.

If you don't expect tons of traffic, I'd say just use 1 Daphne process.

tboulogne commented 5 years ago

Hello,

Thanks for your answer. In a first time, i try to use pushpin, butdid not success to make it works on my mac. (message sent to pushpin, bud did not déliver). I will give it a try again.

If you get any tips, you're wellcome :-).

Thanks for all.

kevinswiber commented 5 years ago

Hey @tboulogne,

A few items to consider:

  1. Make sure your GRIP_URL points to the Pushpin HTTP Control API.

    # default local Pushpin HTTP Control API
    GRIP_URL = 'http://localhost:5561'
  2. Make sure your Pushpin configuration has the proper route setup in the routesfile.

    * http://localhost:8000

    Replace localhost:8000 with whatever your app's <host>:<port> combination is.

  3. Make sure that when you're accessing your site, you're doing so through the Pushpin URL and not the app URL. By default, Pushpin will listen at http://localhost:7999.

Let us know if you have any additional questions!

tboulogne commented 5 years ago

hey @kevinswiber,

Thanks for insights.

Point 3 mean, that the upstream backend for nginx is pushpin and not daphne ?

tboulogne commented 5 years ago

@kevinswiber i got a working pushpin :-) !

Bu if face randomly lost connection on some statics files : image

Any tips to improve this please ?

Thanks for all.

Regards

jkarneges commented 5 years ago

Weird. Is this easy to reproduce? Can you share the logs from pushpin-proxy.log around the time this happens?

tboulogne commented 5 years ago

hello,

Sorry for the delay. As i need to progress on this project, i switch back to one instance. But i will take some time and back to you with details.

Could hold this case for now if you want.

Regards.