I've attempted to make an Azure Web App using Django. For the past couple days, I've mingled with Websockets for use for a real-time chat locally using the ws protocol. But, when deploying on Azure, I am forced to use the wss protocol due to the website being hosted on https. I've done some research on how to configure wss to no avail. Can anyone help?
I initiate the connection using:
if (window.location.protocol == 'https:') {
wsProtocol = 'wss://'
} else {wsProtocol = 'ws://'}
const chatSocket = new WebSocket(wsProtocol + window.location.host + "/");
This gives: "WebSocket connection to 'wss://pharma-send.azurewebsites.net/' failed:"
I'm using django-channels.
In the Startup Command of my Azure app I've tried running the Gunicorn server with ASGI using
gunicorn pharmasend.asgi:application --bind 0.0.0.0:8000 -w 2 -k uvicorn.workers.UvicornWorker
Although, this hasn't changed anything. Do I need to run an ASGI server, like Daphne or Uvicorn? Or, does Azure's Oryx do it for me?
Thanks for helping!
Related
I have a nextjs app and Django app running on a Linux server. For the purposes of SSR, I am trying to get data from the Django app to the nextjs app using getServerSideProps. The easiest I would do this is to send a request from the nextjs app to the Django app.
This was relatively easy for me to do in development. Requests would be sent to http://localhost:8000, since the Django app was using port 8000, from port 3000 which is the port the nextjs app is using.
However, in our production server, the Django app run on a Unix socket, served via gunicorn.
upstream app_server {
server unix:/path/to/gunicorn.sock fail_timeout=0;
}
How can I request for data from the Django app to the nextjs app when the Django app is accessible via Unix socket?
I deployed my locally functioning django project with two apps to the GAE.
I also tested the MySQL DB at GCP by using the proxy tool provided by GCP.
Although I have successfully deployed the project to the App Engine, it is not working on the GAE.
I tested the URL with Chrome, IE and Safari.
This is what Chrome says:
This site can’t provide a secure connection <project-id>.oa.r.appspot.com sent an invalid response.
Try running Windows Network Diagnostics.
ERR_SSL_PROTOCOL_ERROR
This is what curl says:
(ll_env)> curl https://<project-id>.oa.r.appspot.com
curl : The request was aborted: Could not create SSL/TLS secure channel.
At line:1 char:1
+ curl https://<project-id>.oa.r.appspot.com
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
I tested following settings without success:
USE_X_FORWARDED_HOST = True on the settings.py
ALLOWED_HOSTS = ['*'] on the settings.py
I installed Wireshark and captured the connection setup. App Engine seems to reset my connection request.
django website is working fine on localhost but when hosted on server using nginx and gunicorn, some APIs are throwing 500 server error. This problem is with some APIs and rest of the APIs are working well. Please help me what should I do?
Please, I need to configure Django Channels on redis-channel-layer on windows IIS in production. It is running very well in development.
I have installed redis, daphne. I have set the IIS as proxy server with URL Rewrite pointing the Inbound to localhost 6379 to redis-layer channels. I used python manage.py runworker. and also started the daphne server with the daphne command.
They all ran very well, but there is no websocket handshake for my url.
I have a ubuntu server hosting a web page driven by Python Django, I can access that page by using the following command:elinks http:// 127.0.0.1:8000.
Now if I want to access that same web page on a macbook sharing the same home router with my ubuntu server(local ip: 10.0.0.9), how would I do it? Typing in elinks http:// 10.0.0.9:8000 wouldn't work.
Thanks a lot,
ZZ
Are you running the development server using manage.py?
If so, you should start the server using:
python manage.py runserver 0.0.0.0:8000
This will allow the development server to be visited by ips on all interfaces instead of just localhost.
You need to serve it. There are a number of ways to do this, but my preferred method is to use Nginx as a reverse proxy server for gunicorn. This is a good tutorial for that.