Giter Site home page Giter Site logo

Unix File Socket Argument about daphne HOT 12 OPEN

sourcesolver avatar sourcesolver commented on June 12, 2024
Unix File Socket Argument

from daphne.

Comments (12)

carltongibson avatar carltongibson commented on June 12, 2024

Is the /{app_name}/ a literal?

from daphne.

sourcesolver avatar sourcesolver commented on June 12, 2024

{app_name} is not a literal. It is pseudo-code for the name of the app on the path.

from daphne.

carltongibson avatar carltongibson commented on June 12, 2024

OK, then I'm not sure what to say.

This works AFAICS:

% daphne -u app.socket app:application

... so it's something particular about your setup.

from daphne.

sourcesolver avatar sourcesolver commented on June 12, 2024

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

from daphne.

sourcesolver avatar sourcesolver commented on June 12, 2024

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
2024-02-07 19:42:43,033 INFO HTTP/2 support enabled
2024-02-07 19:42:43,033 INFO Configuring endpoint unix:socket.lock
2024-02-07 19:42:43,033 CRITICAL Listen failure: [Errno 13] Permission denied: '276285' -> b'socket.lock.lock'

So based on that doubling-up of the lock extension in the log, it appears I should not include it...

from daphne.

sourcesolver avatar sourcesolver commented on June 12, 2024

Also tried quoting the socket file argument; same error...

/usr/bin/python3 /usr/bin/daphne -u "socket.lock" {app_name}.asgi:application

from daphne.

carltongibson avatar carltongibson commented on June 12, 2024

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 )

from daphne.

sourcesolver avatar sourcesolver commented on June 12, 2024

I did try it interactively in the context of the username the service uses and the WorkingDirectory -same error

from daphne.

sourcesolver avatar sourcesolver commented on June 12, 2024

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
2024-02-07 20:12:32,346 INFO Starting server at unix:blah
2024-02-07 20:12:32,346 INFO HTTP/2 support enabled
2024-02-07 20:12:32,346 INFO Configuring endpoint unix:blah
2024-02-07 20:12:32,347 CRITICAL Listen failure: [Errno 13] Permission denied: '278322' -> b'blah.lock'

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

from daphne.

sourcesolver avatar sourcesolver commented on June 12, 2024

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

from daphne.

sourcesolver avatar sourcesolver commented on June 12, 2024

What distro are you using?

from daphne.

carltongibson avatar carltongibson commented on June 12, 2024

You can examine the socket_description here:

https://github.com/django/daphne/blob/9a282dd6277f4b921e494a9fc30a534a7f0d6ca6/daphne/server.py#L130C1-L131C1

It's definitely a string type when it leaves Daphne. Whatever is going on beyond that is inside twisted.

from daphne.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.