-
Notifications
You must be signed in to change notification settings - Fork 267
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
Unix File Socket Argument #498
Comments
Is the |
{app_name} is not a literal. It is pseudo-code for the name of the app on the path. |
OK, then I'm not sure what to say. This works AFAICS:
... so it's something particular about your setup. |
I tried ExecStart=/usr/bin/python3 /usr/bin/daphne -u socket {app_name}.asgi:application I get back: CRITICAL Listen failure: [Errno 22] Invalid argument: b'socket.lock' Yes, it's something particular about my setup. Most likely it's the implementation of twisted on debian 12 vs. daphne. Twisted use to be python2. It appears to be a mismatch in argument passing between a bytestring and a utf8 one. For some reason the daphne looks like it's passing the file socket parameter as a bytestring to twisted when it should be passing it as utf8 |
When I do: /usr/bin/python3 /usr/bin/daphne -u socket.lock {app_name}.asgi:application (add the .lock extension to the unix file...), I get: 2024-02-07 19:42:43,032 INFO Starting server at unix:socket.lock So based on that doubling-up of the lock extension in the log, it appears I should not include it... |
Also tried quoting the socket file argument; same error... /usr/bin/python3 /usr/bin/daphne -u "socket.lock" {app_name}.asgi:application |
Does it work if you run Daphne manually rather than via systemd? (To be honest, without a reproduce I'm going to struggle to help you ) |
I did try it interactively in the context of the username the service uses and the WorkingDirectory -same error |
I tried a random socket file name (that does not exist): /usr/bin/python3 /usr/bin/daphne -u blah {app_name}.asgi:application /usr/bin/python3 /usr/bin/daphne -u blah {app_name}.asgi:application Got that permission error. When you have it reference a socket file that exists, has the service's user and group ownership, and rwx permissions for both the user and group, you still get that invalid argument error, showing that a bytestring is being passed |
The socket file argument SHOULD be able to take a fully qualified path; and I tested that I can touch the socket file, so a permissions thing doesn't appear to be coming into play. It's saying the path is bad. Only thing I can come up with is that twisted is being passed a bytestring when it now expects utf8 |
What distro are you using? |
You can examine the It's definitely a string type when it leaves Daphne. Whatever is going on beyond that is inside twisted. |
I think that must be right. Short of an actionable change here, I'm going to close as an upstream issue. Sorry I can't be more help. |
It appears there is a bug in daphne using file sockets on debian bookworm.
When I do the following from my service file:
the log file says:
2024-02-05 04:44:20,299 INFO Starting server at unix:/var/run/{app_name}/socket
2024-02-05 04:44:20,299 INFO HTTP/2 support enabled
2024-02-05 04:44:20,299 INFO Configuring endpoint unix:/var/run/{app_name}/socket
2024-02-05 04:44:20,300 CRITICAL Listen failure: [Errno 22] Invalid argument: b'/var/run/{app_name}/socket.lock'
[Note: the folder "/var/run/{app_name}" and file "/var/run/{app_name}/socket.lock" has been created beforehand by tmpfiles.d, with ample username+group permissions, as used by the service; I confirmed this with an ls -l...]
Note the:
It appears a bytestring is getting passed to twisted when it should be a utf8 string?
The code in endpoints.py at startup does:
In server.py we have an error callback:
How can this be corrected, either by command switch fixup or component installation or hotfix, so that we do not get this error when we use a unix file socket?
python version is 3.11.2
Daphne version is 4.0.0
twisted version is 23.10.0
Running on debian 12/bookworm
Thanks much!
The text was updated successfully, but these errors were encountered: