Websockets - Locally Hosted Alternative for Pusher (Now Free)
[deleted]
Kyrne fine with us
- Edited
3.0.0
Presence Channels
- Websocket now features a presence channel that is automatically subscribed to when viewing individual discussions (logged in users only!)
- Typing indicators for those replying to discussions at the bottom
- Shows users that are currently viewing a discussion on the side bar
- Easy extending (see dev guide below)
Statistics (beta)
- See how things are going with your websocket server
- Peak connection and websocket message counters now on the dashboard of your admin page
- Configurable interval for statistics to cater to your forum's traffic
- Stats are automatically deleted after 10 days
- There will be a blank box on your dashboard until you have your first statistic
Notes
- The api changed a bit in this release, if you hook into websocket, take a look at the guide below
- Statistics are only enabled for the non-Poxa server. While I didn't find any performance difference with stats on vs off, this is to keep Poxa as the most high-performance option
- The chart may need to be tweaked in the future depending on feedback. If you can't see some data, or the scale is wrong, feel free to reach out to me
Installing
- Shutdown your running websocket server
- Update the plugin
composer update kyrne/websocket
- Run the migrations
php flarum migrate
- Clear your cache
php flarum cache:clear
as well as any Cloudflare or other server caches - Configure the stats interval on the websocket admin page
- Start the websocket server once again
- Wait for the first interval to pass and check the graph!
Dev Notes
- You now have a dedicated way to access the pusher instance. Simply resolve the
app.pusher
promise and you will find the pusher instance directly on the returned value's.pusher
key - Channels can now be found under that same value's
.channel
key - The presence channel can be accessed via
app.discussions.presence
, it is automatically updated with the discussion that the user is currently viewing (don't forget to bind to an event each time a new discussion is viewed!)
3.0.3
- Fix statistics saving
- Reverse graph order
- Fix
flarum/statistics
conflict
Please restart the websocket server after updating!
- Edited
HD3D Apache will not have any effect on the setup of the websocket server using my methods. You will only need to utilize the nginx portion. Check the GitHub page for detailed instructions on how to set that up.
If you want to use Apache for it I cannot provide support, I've never attempted it and it doesn't seem like the best method to me as Apache wasn't built with proxy-ing in mind.
- Edited
Kyrne Ok thanks
I'm now using websockets with Option 2 - Websocket server handles SSL
Everything seems to work great but I'm noticing that my forum is hanging after a few minutes and becomes all discussions disappear, it can't be refresh by clicking on the forum logo but only by refreshing the browser's refresh button and then it works for a few minutes and so on
Also, After running php flarum websocket:serve
it is running for minutes, am I suppose to just close the putty like that?
Below is the screenshot of putty constantly running for minutes after running php flarum websocket:serve command
Edit:
I notice that my server is getting automatic restart
These are the console errors when forum goes on blank and refresh mode
Edit2:
Another issue I'm facing is that websockets runs only if I run "php flarum websocket:serve" command in putty and let it run, websockets stops working as soon as I close putty
- Edited
HD3D The php flarum websocket:serve command needs to run constantly. The websocket does not work because the nu command stops working as soon as you exit the console. There are several ways to make this command run continuously. I am using Supervisor. I advise. https://flarumtr.com/d/2293-flarumda-supervisor-usage Here I have explained the supersisior setup and its configuration for websocket. But Turkish.
https://discuss.flarum.org/d/28052-realtime-self-hosted-websocket-for-instant-updates You can also check this for supervisor usage.
HD3D Another issue I'm facing is that websockets runs only if I run "php flarum websocket:serve" command in putty and let it run, websockets stops working as soon as I close putty
This is to be expected. Simplest workaround is nohup php flarum websocket:serve &
. If the machine is running systemd, I would create a systemd service unit.
mekici tuxmain streaps Thanks for the help guys
@Kyrne I have successfully configured websockets through Option 1 - Proxy w/ SSL (Recommended) but there are some issues I'm facing..
Cleared cache, purged CF cache but I still see the text below
When I click on the yellow bar to refresh, it throws the below error on my console