Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a real-time event feed using websockets and Poxa #58

Open
skluck opened this issue Oct 14, 2017 · 1 comment
Open

Create a real-time event feed using websockets and Poxa #58

skluck opened this issue Oct 14, 2017 · 1 comment

Comments

@skluck
Copy link
Member

skluck commented Oct 14, 2017

Since the current frontend is PHP-based and bad at real-time features - we need to use a different technology to make the frontend more responsive.

Poxa is a standalone websocket/pusher service that can handle sending and syncing events from the server side (PHP) to the client side (JS). It is API-compatible with pusher.com.

Data flow

  1. Webserver proxies requests to VHOST/ws to Poxa
  2. JS connects to websocket endpoint.
  3. When events occur, the PHP triggers Poxa over an http API.
  4. Poxa broadcasts the events to any open channels to alert users that are connected.
[ POXA ] ←────→ [ JS FRONTEND ]     [ PHP BACKEND ]
   ↑                                      │
   └──────────────────────────────────────┘

  • Create a new page for prototyping - Admin-only audit feed
  • Add a simple service class for sending events to Poxa (See Pusher PHP client for reference)
  • Add event sending to various "audit actions" (CRUD actions for various resources like apps, targets, etc)
@nagibyro
Copy link

Started looking into poxa. pusher-js doesn't seem to allow you to configure a path for the connection only a hostname. I was able to get Poxa and php talking and got pusher-js working but only if using a different port than the main application.

Nginx as web socket proxy

http{
    map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
    }

    server {
        #different port for websockets
        listen 8888;
        server_name hal-3.localhost;

        location / {
            proxy_pass http://localhost:8080;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
        }
    }
}

@skluck skluck removed the k/research label Jan 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants