{"id":24468,"library":"python3-dtls","title":"Python DTLS","description":"Implementation of Datagram Transport Layer Security (DTLS) for Python. Provides DTLS client and server support over UDP. Current version 1.3.0 has no declared Python version requirement. Release cadence is low, typically one release every few years.","status":"active","version":"1.3.0","language":"python","source_language":"en","source_url":"https://github.com/mcfreis/pydtls","tags":["dtls","udp","tls","security","cryptography"],"install":[{"cmd":"pip install python3-dtls","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Used for cryptographic operations","package":"pycrypto","optional":false},{"reason":"Used for TLS/DTLS handshake and encryption","package":"pyopenssl","optional":false}],"imports":[{"note":"ClientSocket does not exist; correct class is DTLSClientSocket","wrong":"from dtls import ClientSocket","symbol":"DTLSClientSocket","correct":"from dtls import DTLSClientSocket"},{"note":"ServerSocket does not exist; correct class is DTLSServerSocket","wrong":"from dtls import ServerSocket","symbol":"DTLSServerSocket","correct":"from dtls import DTLSServerSocket"}],"quickstart":{"code":"import os\nfrom dtls import DTLSClientSocket, DTLSServerSocket\n\n# Client example\nclient_socket = DTLSClientSocket()\nclient_socket.connect(('localhost', 4433))\nclient_socket.send(b'Hello over DTLS')\ndata = client_socket.recv(1024)\nprint(data)\nclient_socket.close()\n\n# Server example\nserver_socket = DTLSServerSocket()\nserver_socket.bind(('', 4433))\nclient, addr = server_socket.accept()\ndata = client.recv(1024)\nprint('Received:', data)\nclient.send(b'Hello from server')\nclient.close()","lang":"python","description":"Simple DTLS client and server example using DTLSClientSocket and DTLSServerSocket."},"warnings":[{"fix":"Wrap socket operations with timeout or use select module.","message":"The library does not automatically handle DTLS retransmission timers. You must implement application-level timeouts or use threading to avoid blocking on recv() indefinitely if packets are lost.","severity":"gotcha","affected_versions":"<=1.3.0"},{"fix":"Be prepared to migrate to a library supporting DTLS 1.2 or later (e.g., pyOpenSSL with DTLS).","message":"Version 1.3.0 lacks support for DTLS 1.2; only DTLS 1.0 is supported. Upcoming versions may drop DTLS 1.0 completely.","severity":"deprecated","affected_versions":"<=1.3.0"},{"fix":"Install system dependencies: on Ubuntu/Debian run 'sudo apt-get install build-essential libssl-dev libffi-dev' before pip install.","message":"The library depends on pycrypto and pyopenssl. On some platforms, pycrypto may require a C compiler or additional system libraries (e.g., libffi-dev, libssl-dev).","severity":"gotcha","affected_versions":"<=1.3.0"},{"fix":"Use DTLSClientSocket and DTLSServerSocket instead of any previous names.","message":"In version 1.3.0, the DTLSClientSocket and DTLSServerSocket classes were renamed from older names. Code using old class names will break.","severity":"breaking","affected_versions":"1.3.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'pip install python3-dtls' and import as 'from dtls import ...'.","cause":"Library not installed or installed as python3-dtls but import name mismatch.","error":"ModuleNotFoundError: No module named 'dtls'"},{"fix":"Upgrade to the latest version (pip install --upgrade python3-dtls) and use DTLSClientSocket, DTLSServerSocket.","cause":"Using an older version of the library where class names were different.","error":"AttributeError: module 'dtls' has no attribute 'DTLSClientSocket'"},{"fix":"Install pycrypto: 'pip install pycrypto' or 'pip install pycryptodome' as alternative.","cause":"Missing pycrypto dependency.","error":"ImportError: No module named Crypto"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}