Count open socket and channel connections in a Phoenix application












0















Is there a relatively simple, documented way in a Phoenix application to read how many active sockets and channels are currently open at any given time? And more specifically, is it possible to filter this data by topic and other channel connection metadata?



My use case is for analytics on active connections to my backend.



Thanks for any suggestions!










share|improve this question



























    0















    Is there a relatively simple, documented way in a Phoenix application to read how many active sockets and channels are currently open at any given time? And more specifically, is it possible to filter this data by topic and other channel connection metadata?



    My use case is for analytics on active connections to my backend.



    Thanks for any suggestions!










    share|improve this question

























      0












      0








      0








      Is there a relatively simple, documented way in a Phoenix application to read how many active sockets and channels are currently open at any given time? And more specifically, is it possible to filter this data by topic and other channel connection metadata?



      My use case is for analytics on active connections to my backend.



      Thanks for any suggestions!










      share|improve this question














      Is there a relatively simple, documented way in a Phoenix application to read how many active sockets and channels are currently open at any given time? And more specifically, is it possible to filter this data by topic and other channel connection metadata?



      My use case is for analytics on active connections to my backend.



      Thanks for any suggestions!







      websocket elixir phoenix-framework otp phoenix-channels






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 22 '18 at 5:57









      MurcielagoMurcielago

      199111




      199111
























          1 Answer
          1






          active

          oldest

          votes


















          1














          You are looking for Phoenix.Presence. From the documentation:




          Provides Presence tracking to processes and channels.



          This behaviour provides presence features such as fetching presences for a given topic, as well as handling diffs of join and leave events as they occur in real-time. Using this module defines a supervisor and allows the calling module to implement the Phoenix.Tracker behaviour which starts a tracker process to handle presence information.




          Basically, you are supposed to implement Phoenix.Presence behaviour (the almost ready-to-go example is there in docs,) and Phoenix.Tracker according to your needs.






          share|improve this answer
























          • Thanks, I've read through the Presence docs and it seems like it's intended for tracking presences by topic. However, if I have various different topics that belong to the same category (e.g. user:1, user:2) is it possible to track presence for the user category? I haven't seen anything in docs indicating this.

            – Murcielago
            Nov 22 '18 at 23:55











          • You are to implement your own logic tracking whatever you need.

            – Aleksei Matiushkin
            Nov 23 '18 at 3:21











          • I was able to solve this problem by creating a designated main channel that all users connect to in addition to connecting to their own user channel (e.g. user:23). I then intercepted events like presence_diff in the main channel and sent updates only to admins, as regular users should not be able to see presence information of other users, at least as analytics is concerned in my app. I still feel like this solution is kind of a workaround and that a better solution is available, but I haven't been able to find any documented examples of similar things.

            – Murcielago
            Dec 10 '18 at 20:47











          • Do you know of any examples of implementations of custom tracker logic?

            – Murcielago
            Dec 10 '18 at 20:49






          • 1





            @Murcielago have a look at my repo, although this was my first stab at implementing a tracker github.com/denvaar/mmo_server/blob/master/lib/…

            – denvaar
            yesterday











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424691%2fcount-open-socket-and-channel-connections-in-a-phoenix-application%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You are looking for Phoenix.Presence. From the documentation:




          Provides Presence tracking to processes and channels.



          This behaviour provides presence features such as fetching presences for a given topic, as well as handling diffs of join and leave events as they occur in real-time. Using this module defines a supervisor and allows the calling module to implement the Phoenix.Tracker behaviour which starts a tracker process to handle presence information.




          Basically, you are supposed to implement Phoenix.Presence behaviour (the almost ready-to-go example is there in docs,) and Phoenix.Tracker according to your needs.






          share|improve this answer
























          • Thanks, I've read through the Presence docs and it seems like it's intended for tracking presences by topic. However, if I have various different topics that belong to the same category (e.g. user:1, user:2) is it possible to track presence for the user category? I haven't seen anything in docs indicating this.

            – Murcielago
            Nov 22 '18 at 23:55











          • You are to implement your own logic tracking whatever you need.

            – Aleksei Matiushkin
            Nov 23 '18 at 3:21











          • I was able to solve this problem by creating a designated main channel that all users connect to in addition to connecting to their own user channel (e.g. user:23). I then intercepted events like presence_diff in the main channel and sent updates only to admins, as regular users should not be able to see presence information of other users, at least as analytics is concerned in my app. I still feel like this solution is kind of a workaround and that a better solution is available, but I haven't been able to find any documented examples of similar things.

            – Murcielago
            Dec 10 '18 at 20:47











          • Do you know of any examples of implementations of custom tracker logic?

            – Murcielago
            Dec 10 '18 at 20:49






          • 1





            @Murcielago have a look at my repo, although this was my first stab at implementing a tracker github.com/denvaar/mmo_server/blob/master/lib/…

            – denvaar
            yesterday
















          1














          You are looking for Phoenix.Presence. From the documentation:




          Provides Presence tracking to processes and channels.



          This behaviour provides presence features such as fetching presences for a given topic, as well as handling diffs of join and leave events as they occur in real-time. Using this module defines a supervisor and allows the calling module to implement the Phoenix.Tracker behaviour which starts a tracker process to handle presence information.




          Basically, you are supposed to implement Phoenix.Presence behaviour (the almost ready-to-go example is there in docs,) and Phoenix.Tracker according to your needs.






          share|improve this answer
























          • Thanks, I've read through the Presence docs and it seems like it's intended for tracking presences by topic. However, if I have various different topics that belong to the same category (e.g. user:1, user:2) is it possible to track presence for the user category? I haven't seen anything in docs indicating this.

            – Murcielago
            Nov 22 '18 at 23:55











          • You are to implement your own logic tracking whatever you need.

            – Aleksei Matiushkin
            Nov 23 '18 at 3:21











          • I was able to solve this problem by creating a designated main channel that all users connect to in addition to connecting to their own user channel (e.g. user:23). I then intercepted events like presence_diff in the main channel and sent updates only to admins, as regular users should not be able to see presence information of other users, at least as analytics is concerned in my app. I still feel like this solution is kind of a workaround and that a better solution is available, but I haven't been able to find any documented examples of similar things.

            – Murcielago
            Dec 10 '18 at 20:47











          • Do you know of any examples of implementations of custom tracker logic?

            – Murcielago
            Dec 10 '18 at 20:49






          • 1





            @Murcielago have a look at my repo, although this was my first stab at implementing a tracker github.com/denvaar/mmo_server/blob/master/lib/…

            – denvaar
            yesterday














          1












          1








          1







          You are looking for Phoenix.Presence. From the documentation:




          Provides Presence tracking to processes and channels.



          This behaviour provides presence features such as fetching presences for a given topic, as well as handling diffs of join and leave events as they occur in real-time. Using this module defines a supervisor and allows the calling module to implement the Phoenix.Tracker behaviour which starts a tracker process to handle presence information.




          Basically, you are supposed to implement Phoenix.Presence behaviour (the almost ready-to-go example is there in docs,) and Phoenix.Tracker according to your needs.






          share|improve this answer













          You are looking for Phoenix.Presence. From the documentation:




          Provides Presence tracking to processes and channels.



          This behaviour provides presence features such as fetching presences for a given topic, as well as handling diffs of join and leave events as they occur in real-time. Using this module defines a supervisor and allows the calling module to implement the Phoenix.Tracker behaviour which starts a tracker process to handle presence information.




          Basically, you are supposed to implement Phoenix.Presence behaviour (the almost ready-to-go example is there in docs,) and Phoenix.Tracker according to your needs.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 22 '18 at 7:06









          Aleksei MatiushkinAleksei Matiushkin

          82.5k95692




          82.5k95692













          • Thanks, I've read through the Presence docs and it seems like it's intended for tracking presences by topic. However, if I have various different topics that belong to the same category (e.g. user:1, user:2) is it possible to track presence for the user category? I haven't seen anything in docs indicating this.

            – Murcielago
            Nov 22 '18 at 23:55











          • You are to implement your own logic tracking whatever you need.

            – Aleksei Matiushkin
            Nov 23 '18 at 3:21











          • I was able to solve this problem by creating a designated main channel that all users connect to in addition to connecting to their own user channel (e.g. user:23). I then intercepted events like presence_diff in the main channel and sent updates only to admins, as regular users should not be able to see presence information of other users, at least as analytics is concerned in my app. I still feel like this solution is kind of a workaround and that a better solution is available, but I haven't been able to find any documented examples of similar things.

            – Murcielago
            Dec 10 '18 at 20:47











          • Do you know of any examples of implementations of custom tracker logic?

            – Murcielago
            Dec 10 '18 at 20:49






          • 1





            @Murcielago have a look at my repo, although this was my first stab at implementing a tracker github.com/denvaar/mmo_server/blob/master/lib/…

            – denvaar
            yesterday



















          • Thanks, I've read through the Presence docs and it seems like it's intended for tracking presences by topic. However, if I have various different topics that belong to the same category (e.g. user:1, user:2) is it possible to track presence for the user category? I haven't seen anything in docs indicating this.

            – Murcielago
            Nov 22 '18 at 23:55











          • You are to implement your own logic tracking whatever you need.

            – Aleksei Matiushkin
            Nov 23 '18 at 3:21











          • I was able to solve this problem by creating a designated main channel that all users connect to in addition to connecting to their own user channel (e.g. user:23). I then intercepted events like presence_diff in the main channel and sent updates only to admins, as regular users should not be able to see presence information of other users, at least as analytics is concerned in my app. I still feel like this solution is kind of a workaround and that a better solution is available, but I haven't been able to find any documented examples of similar things.

            – Murcielago
            Dec 10 '18 at 20:47











          • Do you know of any examples of implementations of custom tracker logic?

            – Murcielago
            Dec 10 '18 at 20:49






          • 1





            @Murcielago have a look at my repo, although this was my first stab at implementing a tracker github.com/denvaar/mmo_server/blob/master/lib/…

            – denvaar
            yesterday

















          Thanks, I've read through the Presence docs and it seems like it's intended for tracking presences by topic. However, if I have various different topics that belong to the same category (e.g. user:1, user:2) is it possible to track presence for the user category? I haven't seen anything in docs indicating this.

          – Murcielago
          Nov 22 '18 at 23:55





          Thanks, I've read through the Presence docs and it seems like it's intended for tracking presences by topic. However, if I have various different topics that belong to the same category (e.g. user:1, user:2) is it possible to track presence for the user category? I haven't seen anything in docs indicating this.

          – Murcielago
          Nov 22 '18 at 23:55













          You are to implement your own logic tracking whatever you need.

          – Aleksei Matiushkin
          Nov 23 '18 at 3:21





          You are to implement your own logic tracking whatever you need.

          – Aleksei Matiushkin
          Nov 23 '18 at 3:21













          I was able to solve this problem by creating a designated main channel that all users connect to in addition to connecting to their own user channel (e.g. user:23). I then intercepted events like presence_diff in the main channel and sent updates only to admins, as regular users should not be able to see presence information of other users, at least as analytics is concerned in my app. I still feel like this solution is kind of a workaround and that a better solution is available, but I haven't been able to find any documented examples of similar things.

          – Murcielago
          Dec 10 '18 at 20:47





          I was able to solve this problem by creating a designated main channel that all users connect to in addition to connecting to their own user channel (e.g. user:23). I then intercepted events like presence_diff in the main channel and sent updates only to admins, as regular users should not be able to see presence information of other users, at least as analytics is concerned in my app. I still feel like this solution is kind of a workaround and that a better solution is available, but I haven't been able to find any documented examples of similar things.

          – Murcielago
          Dec 10 '18 at 20:47













          Do you know of any examples of implementations of custom tracker logic?

          – Murcielago
          Dec 10 '18 at 20:49





          Do you know of any examples of implementations of custom tracker logic?

          – Murcielago
          Dec 10 '18 at 20:49




          1




          1





          @Murcielago have a look at my repo, although this was my first stab at implementing a tracker github.com/denvaar/mmo_server/blob/master/lib/…

          – denvaar
          yesterday





          @Murcielago have a look at my repo, although this was my first stab at implementing a tracker github.com/denvaar/mmo_server/blob/master/lib/…

          – denvaar
          yesterday




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424691%2fcount-open-socket-and-channel-connections-in-a-phoenix-application%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          How to fix TextFormField cause rebuild widget in Flutter

          Npm cannot find a required file even through it is in the searched directory