Sockets

class uwsgiconf.options.networking_sockets.Socket(address, *, bound_workers=None, modifier=None)
Parameters:
  • address (str|SocketShared) – Address ([host]:port or socket file) to bind socket to.
  • bound_workers (str|int|list) – Map socket to specific workers. As you can bind a uWSGI instance to multiple sockets, you can use this option to map specific workers to specific sockets to implement a sort of in-process Quality of Service scheme. If you host multiple apps in the same uWSGI instance, you can easily dedicate resources to each of them.
  • modifier (Modifier) – Socket routing modifier.
class uwsgiconf.options.networking_sockets.SocketDefault(address, *, bound_workers=None, modifier=None)

Bind using default protocol. See default_socket_type option.

Parameters:
  • address (str|SocketShared) – Address ([host]:port or socket file) to bind socket to.
  • bound_workers (str|int|list) – Map socket to specific workers. As you can bind a uWSGI instance to multiple sockets, you can use this option to map specific workers to specific sockets to implement a sort of in-process Quality of Service scheme. If you host multiple apps in the same uWSGI instance, you can easily dedicate resources to each of them.
  • modifier (Modifier) – Socket routing modifier.
class uwsgiconf.options.networking_sockets.SocketHttp(address, *, http11=False, bound_workers=None, modifier=None)

Bind to the specified socket using HTTP

Parameters:
  • address (str|SocketShared) – Address ([host]:port or socket file) to bind socket to.
  • http11 (bool) –

    Keep-Alive support. If set the server will try to maintain the connection opened if a bunch of rules are respected.

    This is not a smart http 1.1 parser (to avoid parsing the whole response) but assumes the developer is generating the right headers.

    This has been added to support RTSP protocol for video streaming.

  • bound_workers (str|int|list) – Map socket to specific workers. As you can bind a uWSGI instance to multiple sockets, you can use this option to map specific workers to specific sockets to implement a sort of in-process Quality of Service scheme. If you host multiple apps in the same uWSGI instance, you can easily dedicate resources to each of them.
  • modifier (Modifier) – Socket routing modifier.
class uwsgiconf.options.networking_sockets.SocketHttps(address, *, cert, key, ciphers=None, client_ca=None, bound_workers=None, modifier=None)

Bind to the specified socket using HTTPS

Parameters:
  • address (str|SocketShared) – Address ([host]:port or socket file) to bind socket to.
  • cert (str) – Certificate file.
  • key (str) – Private key file.
  • ciphers (str) –

    Ciphers [alias] string.

    Example:
    • DEFAULT
    • HIGH
    • DHE, EDH
  • client_ca (str) –

    Client CA file for client-based auth.

  • bound_workers (str|int|list) – Map socket to specific workers. As you can bind a uWSGI instance to multiple sockets, you can use this option to map specific workers to specific sockets to implement a sort of in-process Quality of Service scheme. If you host multiple apps in the same uWSGI instance, you can easily dedicate resources to each of them.
  • modifier (Modifier) – Socket routing modifier.
classmethod get_certbot_paths(domain: str) → Tuple[str, str]

Returns a tuple of paths for files (certificates_chain, private_key) from Certbot https://certbot.eff.org

Those paths can be used to pass into Socket initializer.

Note

If files not found empty strings are returned.

Parameters:domain – Domain name to get filepaths for.
class uwsgiconf.options.networking_sockets.SocketUwsgi(address, *, persistent=False, bound_workers=None, modifier=None)

uwSGI specific socket using uwsgi protocol.

Parameters:
  • address (str|SocketShared) – Address ([host]:port or socket file) to bind socket to.
  • persistent (bool) – Use persistent uwsgi protocol (puwsgi).
  • bound_workers (str|int|list) – Map socket to specific workers. As you can bind a uWSGI instance to multiple sockets, you can use this option to map specific workers to specific sockets to implement a sort of in-process Quality of Service scheme. If you host multiple apps in the same uWSGI instance, you can easily dedicate resources to each of them.
  • modifier (Modifier) – Socket routing modifier.
class uwsgiconf.options.networking_sockets.SocketUwsgis(address, *, cert, key, ciphers=None, client_ca=None, bound_workers=None, modifier=None)

uwSGI specific socket using uwsgi protocol over SSL.

Parameters:
  • address (str|SocketShared) – Address ([host]:port or socket file) to bind socket to.
  • cert (str) – Certificate file.
  • key (str) – Private key file.
  • ciphers (str) –

    Ciphers [alias] string.

    Example:
    • DEFAULT
    • HIGH
    • DHE, EDH
  • client_ca (str) –

    Client CA file for client-based auth.

  • bound_workers (str|int|list) – Map socket to specific workers. As you can bind a uWSGI instance to multiple sockets, you can use this option to map specific workers to specific sockets to implement a sort of in-process Quality of Service scheme. If you host multiple apps in the same uWSGI instance, you can easily dedicate resources to each of them.
  • modifier (Modifier) – Socket routing modifier.
class uwsgiconf.options.networking_sockets.SocketUdp(address, *, bound_workers=None, modifier=None)

Run the udp server on the specified address.

Note

Mainly useful for SNMP or shared UDP logging.

Parameters:
  • address (str|SocketShared) – Address ([host]:port or socket file) to bind socket to.
  • bound_workers (str|int|list) – Map socket to specific workers. As you can bind a uWSGI instance to multiple sockets, you can use this option to map specific workers to specific sockets to implement a sort of in-process Quality of Service scheme. If you host multiple apps in the same uWSGI instance, you can easily dedicate resources to each of them.
  • modifier (Modifier) – Socket routing modifier.
class uwsgiconf.options.networking_sockets.SocketFastcgi(address, *, nph=False, bound_workers=None, modifier=None)

Bind to the specified socket using FastCGI.

Parameters:
  • address (str|SocketShared) – Address ([host]:port or socket file) to bind socket to.
  • nph (bool) – Use NPH mode (“no-parsed-header” - bypass the server completely by sending the complete HTTP header directly to the browser).
  • bound_workers (str|int|list) – Map socket to specific workers. As you can bind a uWSGI instance to multiple sockets, you can use this option to map specific workers to specific sockets to implement a sort of in-process Quality of Service scheme. If you host multiple apps in the same uWSGI instance, you can easily dedicate resources to each of them.
  • modifier (Modifier) – Socket routing modifier.
class uwsgiconf.options.networking_sockets.SocketScgi(address, *, nph=False, bound_workers=None, modifier=None)

Bind to the specified UNIX/TCP socket using SCGI protocol.

Parameters:
  • address (str|SocketShared) – Address ([host]:port or socket file) to bind socket to.
  • nph (bool) – Use NPH mode (“no-parsed-header” - bypass the server completely by sending the complete HTTP header directly to the browser).
  • bound_workers (str|int|list) – Map socket to specific workers. As you can bind a uWSGI instance to multiple sockets, you can use this option to map specific workers to specific sockets to implement a sort of in-process Quality of Service scheme. If you host multiple apps in the same uWSGI instance, you can easily dedicate resources to each of them.
  • modifier (Modifier) – Socket routing modifier.
class uwsgiconf.options.networking_sockets.SocketRaw(address, *, bound_workers=None, modifier=None)

Bind to the specified UNIX/TCP socket using RAW protocol.

Raw mode allows you to directly parse the request in your application callable. Instead of getting a list of CGI vars/headers in your callable you only get the file descriptor soon after accept().

You can then read()/write() to that file descriptor in full freedom.

Note

Raw mode disables request logging.

Warning

Use it as a low-level socket wrapper.

Parameters:
  • address (str|SocketShared) – Address ([host]:port or socket file) to bind socket to.
  • bound_workers (str|int|list) – Map socket to specific workers. As you can bind a uWSGI instance to multiple sockets, you can use this option to map specific workers to specific sockets to implement a sort of in-process Quality of Service scheme. If you host multiple apps in the same uWSGI instance, you can easily dedicate resources to each of them.
  • modifier (Modifier) – Socket routing modifier.
class uwsgiconf.options.networking_sockets.SocketShared(address, *, undeferred=False, bound_workers=None, modifier=None)

Create a shared socket for advanced jailing or IPC purposes.

Allows you to create a socket early in the server’s startup and use it after privileges drop or jailing. This can be used to bind to privileged (<1024) ports.

Shared sockets are a way to share sockets among various uWSGI components: you can use that to share a socket between the fastrouter and uWSGI instance.

Parameters:
  • address (str) – Address ([host]:port or socket file) to bind socket to.
  • undeferred (bool) – Use shared socket undeferred mode.
  • bound_workers (str|int|list) – Map socket to specific workers. As you can bind a uWSGI instance to multiple sockets, you can use this option to map specific workers to specific sockets to implement a sort of in-process Quality of Service scheme. If you host multiple apps in the same uWSGI instance, you can easily dedicate resources to each of them.
  • modifier (Modifier) – Socket routing modifier.
class uwsgiconf.options.networking_sockets.SocketZeromq(address, *, bound_workers=None, modifier=None)

Introduce zeromq pub/sub pair.

Parameters:
  • address (str|SocketShared) – Address ([host]:port or socket file) to bind socket to.
  • bound_workers (str|int|list) – Map socket to specific workers. As you can bind a uWSGI instance to multiple sockets, you can use this option to map specific workers to specific sockets to implement a sort of in-process Quality of Service scheme. If you host multiple apps in the same uWSGI instance, you can easily dedicate resources to each of them.
  • modifier (Modifier) – Socket routing modifier.