Skip to content

Error sending a ping message #418

Description

@decadenza

Issue

The command:

aiocoap-client -m EMPTY coap://10.0.2.0:5683

produces the following error:

Traceback (most recent call last):
  File "pc/aiocoap-venv/bin/aiocoap-client", line 8, in <module>
    sys.exit(sync_main())
             ~~~~~~~~~^^
  File "pc/aiocoap-venv/lib/python3.13/site-packages/aiocoap/cli/client.py", line 684, in sync_main
    asyncio.run(main(args=args))
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "pc/aiocoap-venv/lib/python3.13/site-packages/aiocoap/cli/client.py", line 662, in main
    await single_request_with_context(args)
  File "pc/aiocoap-venv/lib/python3.13/site-packages/aiocoap/cli/client.py", line 578, in single_request_with_context
    await single_request(args, context)
  File "pc/aiocoap-venv/lib/python3.13/site-packages/aiocoap/cli/client.py", line 505, in single_request
    response_data = await requester.response
                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "pc/aiocoap-venv/lib/python3.13/site-packages/aiocoap/protocol.py", line 768, in _run_outer
    await cls._run(app_request, response, weak_observation, protocol, log)
  File "pc/aiocoap-venv/lib/python3.13/site-packages/aiocoap/protocol.py", line 797, in _run
    await protocol.find_remote_and_interface(app_request)
  File "pc/aiocoap-venv/lib/python3.13/site-packages/aiocoap/protocol.py", line 466, in find_remote_and_interface
    if await ri.fill_or_recognize_remote(message):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "pc/aiocoap-venv/lib/python3.13/site-packages/aiocoap/tokenmanager.py", line 214, in fill_or_recognize_remote
    return await self.token_interface.fill_or_recognize_remote(message)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "pc/aiocoap-venv/lib/python3.13/site-packages/aiocoap/transports/tcp.py", line 461, in fill_or_recognize_remote
    if message.requested_scheme == self._scheme:
       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "pc/aiocoap-venv/lib/python3.13/site-packages/aiocoap/message.py", line 776, in requested_scheme
    return self.request.requested_scheme
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'requested_scheme'

Expected behaviour

The client sends an ping message (EMPTY CON).

Other information

$ python3 -m aiocoap.cli.defaults
Python version: 3.13.5 (main, May  5 2026, 21:05:52) [GCC 14.2.0]
aiocoap version: 0.4.17
Modules missing for subsystems:
    dtls: missing DTLSSocket
    oscore: missing cbor2, cryptography, filelock, ge25519, lakers-python
    linkheader: everything there
    prettyprint: missing cbor2, pygments, cbor-diag
    ws: missing websockets
Python platform: linux
Default server transports:  tcpserver:tcpclient:tlsserver:tlsclient:udp6
Selected server transports: tcpserver:tcpclient:tlsserver:tlsclient:udp6
Default client transports:  tcpclient:tlsclient:udp6
Selected client transports: tcpclient:tlsclient:udp6
SO_REUSEPORT available (default, selected): True, True

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementtoolsIssues with the CLI tools shipped with aiocoap

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions