django-private-chat icon indicating copy to clipboard operation
django-private-chat copied to clipboard

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

Open khandelwalronak0809 opened this issue 5 years ago • 18 comments

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

khandelwalronak0809 avatar May 01 '19 09:05 khandelwalronak0809

+1

romankondratiev avatar Jun 03 '19 12:06 romankondratiev

You can look here. https://simpleisbetterthancomplex.com/tutorial/2016/08/09/how-to-deploy-django-applications-on-heroku.html

rupeshkmr avatar Jun 04 '19 06:06 rupeshkmr

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

romankondratiev avatar Jun 04 '19 11:06 romankondratiev

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

rupeshkmr avatar Jun 04 '19 15:06 rupeshkmr

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.

romankondratiev avatar Jun 05 '19 05:06 romankondratiev

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.

rupeshkmr avatar Jun 05 '19 06:06 rupeshkmr

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

Legalas61 avatar Nov 28 '19 20:11 Legalas61

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?

bilalzahoor avatar Apr 08 '20 08:04 bilalzahoor

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

MattBrown88 avatar May 21 '20 17:05 MattBrown88

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.

MattBrown88 avatar Jun 01 '20 14:06 MattBrown88

[email protected]:3354 WebSocket connection to 'wss://0.0.0.0:5002/dq4rjlg08bvt1adsdb8gwuk0ct05mmgn/[email protected]' 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

valentinc94 avatar Jun 12 '20 00:06 valentinc94

@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.

Atiya-Rabbi avatar Apr 28 '21 18:04 Atiya-Rabbi

Hey - I can try to help but you’ll have to send me the error message. To get this, look in the Heroku log files.

I need more information :)

On Wed, Apr 28, 2021 at 1:53 PM Atiya Rabbi @.***> wrote:

@MattBrown88 https://github.com/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.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/Bearle/django-private-chat/issues/40#issuecomment-828699067, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEXMPLPJGAFTCLLPQWRHO3TTLBKQ7ANCNFSM4HJSSEZA .

-- Matt Brown Freelance Software Developer www.MatthewLBrown.com https://MatthewLBrown.com, LinkedIn https://www.linkedin.com/in/matthew-brown-44b91017/

MattBrown88 avatar Apr 28 '21 19:04 MattBrown88

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)

delneg avatar Apr 28 '21 20:04 delneg

@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 avatar Apr 28 '21 23:04 Atiya-Rabbi

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

Atiya-Rabbi avatar Apr 28 '21 23:04 Atiya-Rabbi

That means that you haven’t successfully installed django-private-chat on Heroku

On Wed, Apr 28, 2021 at 6:04 PM Atiya Rabbi @.***> wrote:

@delneg https://github.com/delneg Is django-private-chat2 similar in application as django-private-chat?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Bearle/django-private-chat/issues/40#issuecomment-828835932, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEXMPLLPZOQ647JZ2TGQACDTLCH7JANCNFSM4HJSSEZA .

-- Matt Brown Freelance Software Developer www.MatthewLBrown.com https://MatthewLBrown.com, LinkedIn https://www.linkedin.com/in/matthew-brown-44b91017/

MattBrown88 avatar Apr 29 '21 02:04 MattBrown88

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?

Atiya-Rabbi avatar Apr 29 '21 07:04 Atiya-Rabbi