Troubleshooting OpenLiteSpeed with Django and Daphne: Overcoming 503 Errors

Problem

I recently moved to OpenLiteSpeed Django and have my repository ready to be cloned. I have implemented Daphne to work smoothly with ASGI. However, I am encountering a 503 Service Unavailable error. I am unsure if OpenLiteSpeed can be used without PHP, as it seems to be waiting for PHP to run or is built to work within a PHP environment.

What I Have Tried

  1. Setup:

    • Cloned my repository and set up everything needed for OpenLiteSpeed.
    • Created a Daphne service file and configured it to create a socket file for OpenLiteSpeed to communicate with.
    • Ensured all permissions are set correctly, and verified that the OpenLiteSpeed user “nobody” can access the socket file.
  2. Logs:

    • Checked all logs (access, error, debug) but found no useful information.
    • The only consistent issue is the 503 Service Unavailable error.
  3. Configuration:

    • Removed the Example app block code from the hosts_config.conf file.
    • Tested the syntax with the -t command, and no errors were found.

Question

Can I use OpenLiteSpeed without PHP for my Django app? If not, what could be the best alternative to OpenLiteSpeed that works with ASGI apps and Daphne.

I haven’t looked at OLS in quite a while, and I’ve never tried using it with websockets - so this is what I’m seeing based on the Documentation and a rather cursory examination.

The web admin console for OLS is PHP. So that isn’t going to work if you don’t have any PHP installed. Beyond that, I don’t see where it’s required. (In other words, if you’re willing to manually edit the config files and remove the settings for the web console, I think it should work.)

Did you create two entries for your project? (One for the regular web interface and another for the websocket interface?)
Both entries would be reverse proxies if you’re serving both through Daphne.

Or, if you want your regular Django code to run sync, you could use the OLS Python LSAPI interface.

Is Daphne running? Is it attached to the same socket? (Note: I have found it easier in the past to start with using a TCP socket when trying to get all this configured. It makes more information more easily available when things aren’t working right.)

Side note - In addition to the application-specific logs (OLS and Daphne and your application), are you also checking syslog? (Especially for messages concerning your systemd services.)

I use nginx for this. It has been my webserver-of-choice for more than 10 years now, and the only one I’ve ever deployed for websocket support.

I thank you sir for your reply.
I used Nginx for this app, but I felt that OLS would be much faster than Nginx, so I moved there.
Nginx is one of the top web servers, but it’s a bit old and should be an alternative to it, and OLS is a good one.
If I have seen anything from the syslog. Yes, I did and everything works smoothly except for the 503 Error.
To allow OLS to communicate with Daphne, the best thing is to make Daphne’s service create a socket file, and OLS will use this file for the communication.
Also, the fact, if I have created a new vhost, yes, I did, and I did it for my repo, the actual app.

Anyways, any best alternatives to OLS? has the Speed and best performance as well.

I thank you again sir for your answers.

An opinion that I am inclined to disbelieve. Right now, it’s only a conjecture, with no basis in fact, until proven in your environment, with your code.

Old? Depends upon how you look at it. It’s well maintained. The most recent release was 14 Aug 2024.
(There are probably many things in your development stack that are significantly older. Python is older. Django is older. Mere age is not a criteria for quality.)

I don’t disagree. However, it makes debugging and tracing difficult.

Somtimes the best option to solving a problem is to remove the unconstrained variables, move back to a working configuration, and then work forward from a known good starting point.

Yep. Nginx. I’ve never had a problem with it.

(Any configuration using a web server that works is far superior to one that doesn’t, regardless of any perceived possibility of performance differences.)

One last question, before I go to Nginx again, how about the Nginx Plus? I mean in comparison to the Nginx Open Source?

I’ve never used Nginx Plus, and don’t really know anything about it.

Their web site has a comparison of the two at F5 NGINX Plus: Compare NGINX Models | F5 NGINX.

Thanks, Sir, I appreciate your time and your help, you are the best always.