channels without channel layer or any other free hosting
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
add a comment |
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
add a comment |
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
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
django redis channel django-channels
asked Nov 12 '18 at 23:07
Nimish BansalNimish Bansal
763417
763417
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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"
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
|
show 4 more comments
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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"
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
|
show 4 more comments
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"
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
|
show 4 more comments
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"
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"
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
|
show 4 more comments
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
|
show 4 more comments
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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