Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you please help me on how to run it on heroku? #40

Open
khandelwalronak0809 opened this issue May 1, 2019 · 18 comments
Open

Can you please help me on how to run it on heroku? #40

khandelwalronak0809 opened this issue May 1, 2019 · 18 comments

Comments

@khandelwalronak0809
Copy link

khandelwalronak0809 commented May 1, 2019

Want to run it on heroku or any other server with the main django application. Please help me on this.

@romankondratiev
Copy link

+1

@rupeshkmr
Copy link

@romankondratiev
Copy link

Thank you for reply!
My question (and probably the original question as well) is however, how is it possible to run the chat app on Heroku inside my main Django app.

Should I add another dyno specific for the chat app?
Or how can I ran the command python manage.py run_chat_server while deploying on Heroku?

Thank you very much in advance

@rupeshkmr
Copy link

You want to test the application on heroku?
After final migration the application will automatically be deployed on heroku.

@romankondratiev
Copy link

So please correct me if I'm wrong: you are saying that the chat should work on Heroku without any further configurations?

My main app including chat are deployed on Heroku, all migrations are run, but the chat doesn't work for some reasons. The messages are not getting sent, whereas locally it works fine.

@rupeshkmr
Copy link

You'll need to add configurations required for chat app.
For simplicity you can try python anywhere. It allows you to upload your own virtualenv and run app.

@jic8
Copy link

jic8 commented Nov 28, 2019

I have a similar problem. Everything works on the local server, but no messages are sent to Heroku.
I run heroku run bash and python manage.py run_chat_server Server starts without errors.
My settings.py
CHAT_WS_SERVER_HOST = '0.0.0.0' CHAT_WS_SERVER_PORT = 5002 CHAT_WS_SERVER_PROTOCOL = 'wss' DATETIME_FORMAT = "d N в H:i"
I am using https protocol. In the browser console WebSocket connection to 'wss://0.0.0.0:5002/dfs5k7c05k20w236xxhvelsrfm2adpgo/devkd' failed: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR

@bilalzahoor
Copy link

I want to host the application on heroku, Everything works as expected on local server, but while deploying on heroku chat server is not working. I am getting the error :
OSError: [Errno 99] error while attempting to bind on address ('XX.XX.XXX.XX', XXXX): cannot assign requested address.
Procfile contents are:
web: gunicorn chatApp.wsgi --log-file -
worker: python manage.py run_chat_server
I m running run_chat_server command on seperate worker dyno
In settings.py chat server settings are:
CHAT_WS_SERVER_HOST = 'myappname.herokuapp.com'
CHAT_WS_SERVER_PORT = os.environ['PORT']
CHAT_WS_SERVER_PROTOCOL = 'ws'
Can anyone help me to resolve the error?

@MattBrown88
Copy link
Contributor

I'm experiencing the same issue as @bilalzahoor. Has anyone been able to resolve this?

@MattBrown88
Copy link
Contributor

I was able to get an application with django-private-chat running on Heroku. The key was to run the chat service as a separate Heroku web app. I deployed two versions of the application to separate Heroku apps, only changing the Procfile.

Here are what each Procfile looks like

#Chat Service Procfile
web: python manage.py run_chat_server 
#Django Application Procfile
web: gunicore <app_name>.wsgi

The settings I used were:

#settings.py

CHAT_WS_SERVER_HOST =  '0.0.0.0'
CHAT_WS_SERVER_PROTOCOL = 'wss'
CHAT_WS_SERVER_PORT = int(os.environ.get('PORT', 5002))

In addition, I modified the var base_ws_server_path = ‘wss://<chat-service-app-name>.herokuapp.com/' in templates>django_private_chat>dialogs.html.

Let me know if you have any questions.

@valentinc94
Copy link

sistelca2013@gmail.com:3354 WebSocket connection to 'wss://0.0.0.0:5002/dq4rjlg08bvt1adsdb8gwuk0ct05mmgn/sistelca2013@gmail.com' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

CHAT_WS_SERVER_HOST = '0.0.0.0'
CHAT_WS_SERVER_PORT = 5002
CHAT_WS_SERVER_PROTOCOL = 'wss'
SESSION_COOKIE_AGE = 12096000

in production server :/ i have my ip but doesn't work my demon is this

[Unit]

Description=El Trabajo Deseado Chat

After=network.target

[Service]
EnvironmentFile=/home/ubuntu/etd/eltrabajodeseado/variables.env

User=ubuntu

Group=www-data

WorkingDirectory=/home/ubuntu/etd/eltrabajodeseado

ExecStart=/home/ubuntu/etd-env/bin/python /home/ubuntu/etd/eltrabajodeseado/manage.py run_chat_server

[Install]

WantedBy=multi-user.target

somebody can help me please

@Atiya-Rabbi
Copy link

@MattBrown88
I created two versions of the same Django app and pushed on heroku but it is still showing me application error.
I added the Procfile and updated settings.py in both versions.

@MattBrown88
Copy link
Contributor

MattBrown88 commented Apr 28, 2021 via email

@delneg
Copy link
Collaborator

delneg commented Apr 28, 2021

Please check out https://github.com/Bearle/django_private_chat2
It's using Django Channels and thus must be much simpler to run on heroku (no separate ws server)

@Atiya-Rabbi
Copy link

@MattBrown88 This is what I did

  1. created another folder of the same Django app in my local system.
  2. updated the Procfile
  3. updated settings.py of both apps as mentioned above
  4. also updated allowed hosts in settings.py as ALLOWED_HOSTS = ['abc.herokuapp.com', 'chat-server.herokuapp.com']
    Heroku log files of both apps are showing No module named 'django_private_chat'

@Atiya-Rabbi
Copy link

@delneg
Is django-private-chat2 similar in application as django-private-chat?

@MattBrown88
Copy link
Contributor

MattBrown88 commented Apr 29, 2021 via email

@Atiya-Rabbi
Copy link

Atiya-Rabbi commented Apr 29, 2021

Okay @MattBrown88 , so I added django-private-chat==0.3.0 in requirements.txt now the app is running on Heroku but in the console of my browser it tells me that the WebSocket connection is failed:
WebSocket connection to 'wss://0.0.0.0:43049/paymkzknirnqt5cwoo2cvzgn8hadtyox/username_abc' failed:

It means that WebSocket is in a closed state. I even tried to restart the heroku server, still, I am unable to establish a connection to send and receive messages.

Will you please help me out here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants