channels without channel layer or any other free hosting










0















I have a project in django 2.0 nad django-channlels 2.0 which I need to host I followed the documentation and I was able to run channels on localhost along with redis
but when I hosted on pythonanywhere,it showed it doesnot support websocket, so then I hosted on heroku,but there they were asking for verification of credit card info which i dont have to run redis.Are there additional hosting website whre I can rrun redis erver for free



Or is it poosible to implement channels without channel_layer and redis.My code is working perfectly fine on local host but can't host online for free.



class PageConsumer(WebsocketConsumer):
def connect(self, **kwargs):
self.accept()
channel_layer = get_channel_layer()
async_to_sync(channel_layer.group_send)("admin", "type": "analytics.admin_message", "message": "plus")

def disconnect(self, close_code):
channel_layer = get_channel_layer()
async_to_sync(channel_layer.group_send)("admin", "type": "analytics.admin_message", "message": "minus")


its corresponidng receiver



class ChatConsumer(WebsocketConsumer):
def connect(self, **kwargs):
self.accept()
async_to_sync(self.channel_layer.group_add)("admin", self.channel_name)

def disconnect(self, close_code):
async_to_sync(self.channel_layer.group_discard)("admin", self.channel_name)

def analytics_admin_message(self, something):
if something["message"] == "plus":
self.send(text_data=json.dumps(
'message': "plus"
))

else:
self.send(text_data=json.dumps(
'message': "minus"
))

def receive(self, text_data):
print("data hai bhyi", text_data)
text_data_json = json.loads(text_data)
message = text_data_json['message']

self.send(text_data=json.dumps(
'message': message
))


settings.py



CHANNEL_LAYERS = 
"default":
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG":
"hosts": [("127.0.0.1", 6379)],
,
,










share|improve this question


























    0















    I have a project in django 2.0 nad django-channlels 2.0 which I need to host I followed the documentation and I was able to run channels on localhost along with redis
    but when I hosted on pythonanywhere,it showed it doesnot support websocket, so then I hosted on heroku,but there they were asking for verification of credit card info which i dont have to run redis.Are there additional hosting website whre I can rrun redis erver for free



    Or is it poosible to implement channels without channel_layer and redis.My code is working perfectly fine on local host but can't host online for free.



    class PageConsumer(WebsocketConsumer):
    def connect(self, **kwargs):
    self.accept()
    channel_layer = get_channel_layer()
    async_to_sync(channel_layer.group_send)("admin", "type": "analytics.admin_message", "message": "plus")

    def disconnect(self, close_code):
    channel_layer = get_channel_layer()
    async_to_sync(channel_layer.group_send)("admin", "type": "analytics.admin_message", "message": "minus")


    its corresponidng receiver



    class ChatConsumer(WebsocketConsumer):
    def connect(self, **kwargs):
    self.accept()
    async_to_sync(self.channel_layer.group_add)("admin", self.channel_name)

    def disconnect(self, close_code):
    async_to_sync(self.channel_layer.group_discard)("admin", self.channel_name)

    def analytics_admin_message(self, something):
    if something["message"] == "plus":
    self.send(text_data=json.dumps(
    'message': "plus"
    ))

    else:
    self.send(text_data=json.dumps(
    'message': "minus"
    ))

    def receive(self, text_data):
    print("data hai bhyi", text_data)
    text_data_json = json.loads(text_data)
    message = text_data_json['message']

    self.send(text_data=json.dumps(
    'message': message
    ))


    settings.py



    CHANNEL_LAYERS = 
    "default":
    "BACKEND": "channels_redis.core.RedisChannelLayer",
    "CONFIG":
    "hosts": [("127.0.0.1", 6379)],
    ,
    ,










    share|improve this question
























      0












      0








      0


      1






      I have a project in django 2.0 nad django-channlels 2.0 which I need to host I followed the documentation and I was able to run channels on localhost along with redis
      but when I hosted on pythonanywhere,it showed it doesnot support websocket, so then I hosted on heroku,but there they were asking for verification of credit card info which i dont have to run redis.Are there additional hosting website whre I can rrun redis erver for free



      Or is it poosible to implement channels without channel_layer and redis.My code is working perfectly fine on local host but can't host online for free.



      class PageConsumer(WebsocketConsumer):
      def connect(self, **kwargs):
      self.accept()
      channel_layer = get_channel_layer()
      async_to_sync(channel_layer.group_send)("admin", "type": "analytics.admin_message", "message": "plus")

      def disconnect(self, close_code):
      channel_layer = get_channel_layer()
      async_to_sync(channel_layer.group_send)("admin", "type": "analytics.admin_message", "message": "minus")


      its corresponidng receiver



      class ChatConsumer(WebsocketConsumer):
      def connect(self, **kwargs):
      self.accept()
      async_to_sync(self.channel_layer.group_add)("admin", self.channel_name)

      def disconnect(self, close_code):
      async_to_sync(self.channel_layer.group_discard)("admin", self.channel_name)

      def analytics_admin_message(self, something):
      if something["message"] == "plus":
      self.send(text_data=json.dumps(
      'message': "plus"
      ))

      else:
      self.send(text_data=json.dumps(
      'message': "minus"
      ))

      def receive(self, text_data):
      print("data hai bhyi", text_data)
      text_data_json = json.loads(text_data)
      message = text_data_json['message']

      self.send(text_data=json.dumps(
      'message': message
      ))


      settings.py



      CHANNEL_LAYERS = 
      "default":
      "BACKEND": "channels_redis.core.RedisChannelLayer",
      "CONFIG":
      "hosts": [("127.0.0.1", 6379)],
      ,
      ,










      share|improve this question














      I have a project in django 2.0 nad django-channlels 2.0 which I need to host I followed the documentation and I was able to run channels on localhost along with redis
      but when I hosted on pythonanywhere,it showed it doesnot support websocket, so then I hosted on heroku,but there they were asking for verification of credit card info which i dont have to run redis.Are there additional hosting website whre I can rrun redis erver for free



      Or is it poosible to implement channels without channel_layer and redis.My code is working perfectly fine on local host but can't host online for free.



      class PageConsumer(WebsocketConsumer):
      def connect(self, **kwargs):
      self.accept()
      channel_layer = get_channel_layer()
      async_to_sync(channel_layer.group_send)("admin", "type": "analytics.admin_message", "message": "plus")

      def disconnect(self, close_code):
      channel_layer = get_channel_layer()
      async_to_sync(channel_layer.group_send)("admin", "type": "analytics.admin_message", "message": "minus")


      its corresponidng receiver



      class ChatConsumer(WebsocketConsumer):
      def connect(self, **kwargs):
      self.accept()
      async_to_sync(self.channel_layer.group_add)("admin", self.channel_name)

      def disconnect(self, close_code):
      async_to_sync(self.channel_layer.group_discard)("admin", self.channel_name)

      def analytics_admin_message(self, something):
      if something["message"] == "plus":
      self.send(text_data=json.dumps(
      'message': "plus"
      ))

      else:
      self.send(text_data=json.dumps(
      'message': "minus"
      ))

      def receive(self, text_data):
      print("data hai bhyi", text_data)
      text_data_json = json.loads(text_data)
      message = text_data_json['message']

      self.send(text_data=json.dumps(
      'message': message
      ))


      settings.py



      CHANNEL_LAYERS = 
      "default":
      "BACKEND": "channels_redis.core.RedisChannelLayer",
      "CONFIG":
      "hosts": [("127.0.0.1", 6379)],
      ,
      ,







      django redis channel django-channels






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 '18 at 23:07









      Nimish BansalNimish Bansal

      763417




      763417






















          1 Answer
          1






          active

          oldest

          votes


















          1














          from the docs




          Channel layers are an entirely optional part of Channels as of version 2.0. If you don’t want to use them, just leave CHANNEL_LAYERS unset, or set it to the empty dict .




          It will mean you will be unable to use self.channel_layer in the consumer, which you rely on.



          So, it's optional but you need it.



          In memory exists:



          CHANNEL_LAYERS=
          "default":
          "BACKEND": "channels.layers.InMemoryChannelLayer"







          share|improve this answer

























          • yes I also tried that but after doing that i was unable to find out how should I send message how can I achieve the same functionality that I did above. like group_send,send,because self.channel_layer was returning None as far as I remember

            – Nimish Bansal
            Nov 12 '18 at 23:54











          • exactly what is the use of channel layer?and why it can be set empty?

            – Nimish Bansal
            Nov 12 '18 at 23:55












          • read the docs to understand what it is and why it cannot be set to empty.

            – rikAtee
            Nov 12 '18 at 23:58






          • 1





            In short: you need channels layer config because you're using channels layer. In the same way you need database config of you're using a database.

            – rikAtee
            Nov 12 '18 at 23:59






          • 1





            I googled "Django channels in memory layer"

            – rikAtee
            Nov 13 '18 at 0:12










          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%2f53271407%2fchannels-without-channel-layer-or-any-other-free-hosting%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














          from the docs




          Channel layers are an entirely optional part of Channels as of version 2.0. If you don’t want to use them, just leave CHANNEL_LAYERS unset, or set it to the empty dict .




          It will mean you will be unable to use self.channel_layer in the consumer, which you rely on.



          So, it's optional but you need it.



          In memory exists:



          CHANNEL_LAYERS=
          "default":
          "BACKEND": "channels.layers.InMemoryChannelLayer"







          share|improve this answer

























          • yes I also tried that but after doing that i was unable to find out how should I send message how can I achieve the same functionality that I did above. like group_send,send,because self.channel_layer was returning None as far as I remember

            – Nimish Bansal
            Nov 12 '18 at 23:54











          • exactly what is the use of channel layer?and why it can be set empty?

            – Nimish Bansal
            Nov 12 '18 at 23:55












          • read the docs to understand what it is and why it cannot be set to empty.

            – rikAtee
            Nov 12 '18 at 23:58






          • 1





            In short: you need channels layer config because you're using channels layer. In the same way you need database config of you're using a database.

            – rikAtee
            Nov 12 '18 at 23:59






          • 1





            I googled "Django channels in memory layer"

            – rikAtee
            Nov 13 '18 at 0:12















          1














          from the docs




          Channel layers are an entirely optional part of Channels as of version 2.0. If you don’t want to use them, just leave CHANNEL_LAYERS unset, or set it to the empty dict .




          It will mean you will be unable to use self.channel_layer in the consumer, which you rely on.



          So, it's optional but you need it.



          In memory exists:



          CHANNEL_LAYERS=
          "default":
          "BACKEND": "channels.layers.InMemoryChannelLayer"







          share|improve this answer

























          • yes I also tried that but after doing that i was unable to find out how should I send message how can I achieve the same functionality that I did above. like group_send,send,because self.channel_layer was returning None as far as I remember

            – Nimish Bansal
            Nov 12 '18 at 23:54











          • exactly what is the use of channel layer?and why it can be set empty?

            – Nimish Bansal
            Nov 12 '18 at 23:55












          • read the docs to understand what it is and why it cannot be set to empty.

            – rikAtee
            Nov 12 '18 at 23:58






          • 1





            In short: you need channels layer config because you're using channels layer. In the same way you need database config of you're using a database.

            – rikAtee
            Nov 12 '18 at 23:59






          • 1





            I googled "Django channels in memory layer"

            – rikAtee
            Nov 13 '18 at 0:12













          1












          1








          1







          from the docs




          Channel layers are an entirely optional part of Channels as of version 2.0. If you don’t want to use them, just leave CHANNEL_LAYERS unset, or set it to the empty dict .




          It will mean you will be unable to use self.channel_layer in the consumer, which you rely on.



          So, it's optional but you need it.



          In memory exists:



          CHANNEL_LAYERS=
          "default":
          "BACKEND": "channels.layers.InMemoryChannelLayer"







          share|improve this answer















          from the docs




          Channel layers are an entirely optional part of Channels as of version 2.0. If you don’t want to use them, just leave CHANNEL_LAYERS unset, or set it to the empty dict .




          It will mean you will be unable to use self.channel_layer in the consumer, which you rely on.



          So, it's optional but you need it.



          In memory exists:



          CHANNEL_LAYERS=
          "default":
          "BACKEND": "channels.layers.InMemoryChannelLayer"








          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 13 '18 at 0:04

























          answered Nov 12 '18 at 23:39









          rikAteerikAtee

          4,83552958




          4,83552958












          • yes I also tried that but after doing that i was unable to find out how should I send message how can I achieve the same functionality that I did above. like group_send,send,because self.channel_layer was returning None as far as I remember

            – Nimish Bansal
            Nov 12 '18 at 23:54











          • exactly what is the use of channel layer?and why it can be set empty?

            – Nimish Bansal
            Nov 12 '18 at 23:55












          • read the docs to understand what it is and why it cannot be set to empty.

            – rikAtee
            Nov 12 '18 at 23:58






          • 1





            In short: you need channels layer config because you're using channels layer. In the same way you need database config of you're using a database.

            – rikAtee
            Nov 12 '18 at 23:59






          • 1





            I googled "Django channels in memory layer"

            – rikAtee
            Nov 13 '18 at 0:12

















          • yes I also tried that but after doing that i was unable to find out how should I send message how can I achieve the same functionality that I did above. like group_send,send,because self.channel_layer was returning None as far as I remember

            – Nimish Bansal
            Nov 12 '18 at 23:54











          • exactly what is the use of channel layer?and why it can be set empty?

            – Nimish Bansal
            Nov 12 '18 at 23:55












          • read the docs to understand what it is and why it cannot be set to empty.

            – rikAtee
            Nov 12 '18 at 23:58






          • 1





            In short: you need channels layer config because you're using channels layer. In the same way you need database config of you're using a database.

            – rikAtee
            Nov 12 '18 at 23:59






          • 1





            I googled "Django channels in memory layer"

            – rikAtee
            Nov 13 '18 at 0:12
















          yes I also tried that but after doing that i was unable to find out how should I send message how can I achieve the same functionality that I did above. like group_send,send,because self.channel_layer was returning None as far as I remember

          – Nimish Bansal
          Nov 12 '18 at 23:54





          yes I also tried that but after doing that i was unable to find out how should I send message how can I achieve the same functionality that I did above. like group_send,send,because self.channel_layer was returning None as far as I remember

          – Nimish Bansal
          Nov 12 '18 at 23:54













          exactly what is the use of channel layer?and why it can be set empty?

          – Nimish Bansal
          Nov 12 '18 at 23:55






          exactly what is the use of channel layer?and why it can be set empty?

          – Nimish Bansal
          Nov 12 '18 at 23:55














          read the docs to understand what it is and why it cannot be set to empty.

          – rikAtee
          Nov 12 '18 at 23:58





          read the docs to understand what it is and why it cannot be set to empty.

          – rikAtee
          Nov 12 '18 at 23:58




          1




          1





          In short: you need channels layer config because you're using channels layer. In the same way you need database config of you're using a database.

          – rikAtee
          Nov 12 '18 at 23:59





          In short: you need channels layer config because you're using channels layer. In the same way you need database config of you're using a database.

          – rikAtee
          Nov 12 '18 at 23:59




          1




          1





          I googled "Django channels in memory layer"

          – rikAtee
          Nov 13 '18 at 0:12





          I googled "Django channels in memory layer"

          – rikAtee
          Nov 13 '18 at 0:12

















          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%2f53271407%2fchannels-without-channel-layer-or-any-other-free-hosting%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

          Kleinkühnau

          Makov (Slowakei)

          Deutsches Schauspielhaus