Getting error when deploying the django channels project in railway
byteupai
FREEOP

2 years ago

only chat application not work other functionality working perfectly

frontend error: WebSocket encountered an error:

Chat socket closed unexpectedly:

backend error: Not Found: /ws/chat/2f2ceffd-d524-4f68-881d-7170ea620c37/

all setup done perfectly but now stuck not getting the solution from anywhere

58 Replies

2 years ago

please do not create duplicate posts or cross post


byteupai
FREEOP

2 years ago

sorry do you know solution of it


2 years ago

you need to use Daphne


byteupai
FREEOP

2 years ago

yes already using


2 years ago

that id doesnt bring me to a project


byteupai
FREEOP

2 years ago

wait I will send 9626ee7a-574c-4d61-a75c-2d65bf18c4a3


2 years ago

you arent


byteupai
FREEOP

2 years ago

how to use it?


byteupai
FREEOP

2 years ago

I have added it in my Procfile


byteupai
FREEOP

2 years ago

release: python manage.py migrate

worker: daphne -b 0.0.0.0 -p $PORT charity_pro.asgi:application


2 years ago

you are using a Dockerfile, Procfiles are irrelevant


byteupai
FREEOP

2 years ago

wait


byteupai
FREEOP

2 years ago


byteupai
FREEOP

2 years ago

check this


byteupai
FREEOP

2 years ago

docker file


2 years ago

please enclose that in a code block


byteupai
FREEOP

2 years ago

# Pull official base image
FROM python:3.12-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Set working directory
WORKDIR /app

# Install dependencies
COPY requirements.txt /app/
RUN pip install --upgrade pip
RUN pip install -r requirements.txt

# Copy project
COPY . /app/

# Install gunicorn
RUN pip install gunicorn

# Collect static files
# RUN python manage.py collectstatic --noinput

# Expose the dynamic port (optional, but not necessary)
EXPOSE 8000 

# Use the environment variable $PORT for deployment
CMD ["gunicorn", "-k", "daphne", "-b", "0.0.0.0:$PORT", "charity_pro.asgi:application"]

byteupai
FREEOP

2 years ago

sorry


2 years ago

you can edit discord messages lol


byteupai
FREEOP

2 years ago

brother please help its urgent


2 years ago

2 problems.

  • you are overwriting that CMD line via the start command in the service settings.
  • you are using exec form for that CMD line

byteupai
FREEOP

2 years ago

not getting properly


byteupai
FREEOP

2 years ago

other functionality working perfectly just problem in chat module


2 years ago

please fix the two issues i had just brought up


byteupai
FREEOP

2 years ago

check now


2 years ago

send me your dockerfile


byteupai
FREEOP

2 years ago

yes


byteupai
FREEOP

2 years ago

# Pull official base image
FROM python:3.12-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Set working directory
WORKDIR /app

# Install dependencies
COPY requirements.txt /app/
RUN pip install --upgrade pip
RUN pip install -r requirements.txt

# Copy project
COPY . /app/

# Install gunicorn
RUN pip install gunicorn daphne

# Collect static files
# RUN python manage.py collectstatic --noinput

# Expose the dynamic port (optional, but not necessary)
EXPOSE 8000 

byteupai
FREEOP

2 years ago


release: python manage.py migrate
worker: daphne -b 0.0.0.0 -p $PORT charity_pro.asgi:application

byteupai
FREEOP

2 years ago

Procfile


2 years ago

again, you are using a Dockerfile, the Procfile is totally irrelevant and unused


byteupai
FREEOP

2 years ago

so remove the procfile?


byteupai
FREEOP

2 years ago

and add CMD in dockerfile?


2 years ago

still 2 problems.

  • you are missing a CMD line
  • you are setting a start command in the service settings

byteupai
FREEOP

2 years ago

now I am adding CMD in dockerfile and remove the procfile


byteupai
FREEOP

2 years ago

okay?


byteupai
FREEOP

2 years ago

so this is my dockerfile updated and removed procfile

# Pull official base image
FROM python:3.12-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Set working directory
WORKDIR /app

# Install dependencies
COPY requirements.txt /app/
RUN pip install --upgrade pip
RUN pip install -r requirements.txt

# Copy project
COPY . /app/

# Install gunicorn
RUN pip install gunicorn daphne

# Collect static files
# RUN python manage.py collectstatic --noinput

# Expose the dynamic port (optional, but not necessary)
EXPOSE 8000 

# Use the environment variable $PORT for deployment
CMD ["gunicorn", "-k", "daphne", "-b", "0.0.0.0:$PORT", "charity_pro.asgi:application"]

byteupai
FREEOP

2 years ago

still getting this error: Not Found: /ws/chat/2f2ceffd-d524-4f68-881d-7170ea620c37/


2 years ago

2 problems.

  • you are overwriting that CMD line via the start command in the service settings.
  • you are using exec form for that CMD line

byteupai
FREEOP

2 years ago

brother can you guide me by filename


2 years ago

filename?


byteupai
FREEOP

2 years ago

removed start command from railway


2 years ago

what about it? you havent done that yet


byteupai
FREEOP

2 years ago

no


byteupai
FREEOP

2 years ago

there are many errors comming related to daphne


byteupai
FREEOP

2 years ago

after removing the start command from railway


2 years ago

send your dockerfile please


byteupai
FREEOP

2 years ago

yes


byteupai
FREEOP

2 years ago

FROM python:3.12-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV DJANGO_SETTINGS_MODULE charity_pro.settings  # Properly set DJANGO_SETTINGS_MODULE to point to your settings module

# Set working directory
WORKDIR /app

# Install dependencies
COPY requirements.txt /app/
RUN pip install --upgrade pip
RUN pip install -r requirements.txt

# Copy project files
COPY . /app/

# Install daphne (no need for gunicorn)
RUN pip install daphne

# Expose the dynamic port (optional)
EXPOSE 8000

# Use the environment variable $PORT for deployment
CMD ["sh", "-c", "daphne -b 0.0.0.0 -p $PORT charity_pro.asgi:application"]

byteupai
FREEOP

2 years ago

changed made by chatgpt guide


byteupai
FREEOP

2 years ago

now getting this error:

django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.


2 years ago

this would be an application level issue


byteupai
FREEOP

2 years ago

can you help me with that?


byteupai
FREEOP

2 years ago

solved brother


byteupai
FREEOP

2 years ago

thank you so much


2 years ago

im glad you where able to solve, but please note we can't offer application level support


byteupai
FREEOP

2 years ago

yaa no issue


byteupai
FREEOP

2 years ago

amazing experience with railway


Welcome!

Sign in to your Railway account to join the conversation.

Loading...