• Dev
  • Notifications and Refresh without Pusher, etc.

Kulga They might have something in mind but it seems like the best out of box would be using the pusher service already supported.

As I mentioned earlier, some admins may have reasons they would not want to use a third-party hosted service. So that would not be the optimum out-of-the-box solution.

    11 days later

    Dominion I've been thinking about this..
    I hate to keep referring to wordpress.. but they have a wp-cron.php file that when run, causes it to "update" - so to speak. By default, every action you do on a wordpress site causes wp-cron.php to run.
    This is really, really inefficient but also moderately effective and as you might mention - very out of box supported.
    The problem is, php programs have no sense of time. It is a server-side renderer that generates html pages. This is worsened by the fact that flarum doesn't even refresh when you go from page to page (this is why notifications don't show up until you refresh the page - I noticed this for much longer with noscript).

    Because of that, it's impossible for flarum to mimick what a pusher service provides. Any attempt will have to be a hack (like wp-cron.php) and be hard-coded to pull content on certain clicks. Should it do it on every page scroll? Clicking on discussions? Doing nothing would result in nothing ever showing up as a notification and is almost guaranteed to result in slower page loads (since it's doing more) and potential scaling issues (flarum-cron.php being run every half second on a busy site?) something has to tell flarum that something has changed, please run code to update it.

    Both toby and franz are devs that know magnitudes more then me about php coding, so maybe they have some idea of circumventing wordpress's (and piwiks) best implementation of dealing with the php and time issue.

    But as it stands, I'm sorry to say this, but if you're on a shared hoster, or simply don't want to know how to start and configure services outside of a webserver, you're going to be stuck. There are solutions, but I wouldn't call them optimal :\, or even if they would work as a forum notifier..


    I'm aware that pusher is planning to be rewritten, but it looks like it's primarily focused on other components. I'm hoping it can be slightly modified to permit designating a ip address and port @Toby. If they both follow the same protocol, then it should be a drop in replacement (pusher.com -> slanger, etc) and I can get to testing how well it works, bugs, etc.

      After having read most of this thread I'd like to clarify some technicalities.

      It's very nice to talk about pusher and slanger without knowing what they facilitate. To keep it simple (which it is), both use the same piece of javascript. So switching between those server endpoints is as easy as changing the configuration of listenening and serving.

      Websockets are continuous connections between machines. They can be used to send over data whenever you like. Normal behaviour is that any visitor on a website is registered on some channels and php sends data to these visitors whenever necessary. There are a lot of benefits to using websockets, to mention some:

      • truly knowing whether someone is online (green circles talked about around avatars are exact)
      • no continuous requests to the server asking questions (ajax)
      • direct notifications, not every x minutes, about updates on threads

      To give you some dimensions of use, some of you might know battlelog by EA; it uses pusher almost solely. At work I also implemented websockets (at first slanger, proving less stable we moved to pusher) which notifies accounts immediately about any finished tasks once done, shows us a list of all online accounts in real-time and shows us a dashboard of open tickets.. The application is endless using websockets.

      I'm a big fan of websockets.

      Ps please be aware that pusher is more stable, it also caps maximum payload data. So switching requires you to understand the max length of the data you're sending.

        luceos I think the issue is not the usability of Websockets (they're great!), but the fact that pusher is a paid app. And on top of that, the user has to embed a 64KB js file as well? That's not right.

        And to put icing on the cake, the free version allows for only 20 connections?

        I'd personally rather just use nodejs and the ws module here. (And use the normal html 5 websocket connection api that's like 2 lines of code) Much, much better.

          Wombat i understand what the issue is, that's why i tried to vouch for it. But i understand that it's not always nice to be stuck to additional costs.

            luceos Pusher.com is definitely not bad. But I'm more focused being able to host my own that gets away from arbitrary limits - not to mention I like to control where my data flows and being able to configure it as needed.

            However I just noticed this in flarum/features/

            Enable Pusher integration to have new posts and discussions appear as they happen. Self-hosted push coming soon.

            Guess it's coming up. I can wait then 😛

              Kulga luceos Thanks for the discussion of the issues involved, very enlightening.

              Kulga Enable Pusher integration to have new posts and discussions appear as they happen. Self-hosted push coming soon.

              Perhaps @Toby can enlighten what this means. Otherwise I would have started some ideas to make a donation based (or otherwise less costly) pusher service for flarum forums.

              We'll be making the Pusher extension's host/port configurable so that people can self-host Slanger (if they have a VPS) and hook it up to that.

              We also may do a short-polling implementation like esoTalk for people on shared hosts who don't want to pay for Pusher. Although, this is low priority: Arguably, if your community is bigger than Pusher's free plan can handle, it's probably a good time to move off of a shared host and onto a VPS.

              ashconnor How is its performance, stability, reliability?
              I'm up for whatever the best is, but untii I start testing them, they're more or less equal unless someone else has tested them.

              I haven't benchmarked it but it is written in Go so I'd expect performance to be good.

              Possibly use it for dev and then switch to Pusher if performance is an issue?

                ashconnor Possibly use it for dev and then switch to Pusher if performance is an issue?

                I don't see myself using pusher on even the lowest tier of pricing (not including free). $20/month is far too high for 100 concurrent when 20 is free. Maybe at $3-4/month for 100. (or a middle level of 40 for $4/month)
                Granted, I'm sure they're a great company and they may of adjusted their pricing accordingly, but when my VPS is $4/month, it would make much more sense (to me) to upgrade to a much higher level VPS and run a (or multiple of) pusher implementations to load balance then use it all on a pusher service (something I consider more of a luxury then a necessity)
                I greatly prefer keeping my users data in house as well..

                However, if you don't want to fight with fairly new software and want it to just work without hassle.. I say go for it.

                ashconnor So I figured I'd try and install it.
                It was a bit of a PITA to get it running... but my experience is:

                • Ensure your go (golang) version is greater then 1.1
                • Follow this guide and ensure you have a file named config.json with at least the sample config in your current directory when you run the ipe command

                I also added this to /etc/bash.bashrc to ensure my shell knew where everything was since it wasn't setup automatically for some reason (probably because I had to manually install golang) - you may or may not need to do this.

                # Path
                PATH=$PATH:/usr/local/go/bin
                ## Exports
                
                # Golang variable
                export GOPATH=/usr/local/go/

                Hopefully that helps.. a lot of the errors I got weren't especially clear


                I should note that IPE apparently permits multiple application id's in one config... that could be very useful for splitting up multiple pusher (flarum) installs. Unfortunately, there's not much documentation for the config... but my guess is it's my limited understanding of pusher that's hindering me as to what each of the config options do.

                  6 days later

                  Kulga Looks like most of your issues were just setting up Golang. Setting up Go is a PITA as it expects certain variables to be set and specific folder structure.

                    seenu I've used socket.io quite successfully for node.js based web projects, the automatic fallback to long polling when websockets are unavailable to the client or are blocked by an intermediate party are very nice.

                    I'm not sure how integrating it with the PHP code in Flarum would work as last i checked there were no language bindings for Socket.io other than Node.js. If there are now language bindings for PHP it would be something to look into.

                      seenu possibly, possibly.

                      I'd have to investigate it more to determine if it would be a good library to use for Flarum.