Skip to content

Coap TCP keep alive using ping messages #138

@lcoudeville

Description

@lcoudeville

I'm encountering issues when sending PING messages on a tcp coap (coap+tcp schema) connection. I expected this to be quite simply so I started from the client example.

            initial_request  = Message(code=Code.PING, uri="coap+tcp://%s:%d/blbalba" % self.controller_addr)

            response =  await self.coap_context.request(initial_request).response
            # this works properly, now an TCP connection exists, send PING messages over it.

            ping = Message(code=Code.PING, uri="coap+tcp://%s:%d" % self.controller_addr)

            try:
                await self.coap_context.request(ping).response
            except:
                logging.exception("CoAP ping failed.")
Traceback (most recent call last):
  File "xxx.py", line 211, in _coap_client_keep_alive
    await self.coap_context.request(ping).response
  File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/home/laurens/projects/lynx/components/lynxathome/lah-node/venv/lib/python3.5/site-packages/aiocoap/protocol.py", line 718, in _run_outer
    await cls._run(app_request, response, weak_observation, protocol, log)
  File "/home/laurens/projects/lynx/components/lynxathome/lah-node/venv/lib/python3.5/site-packages/aiocoap/protocol.py", line 743, in _run
    await protocol.find_remote_and_interface(app_request)
  File "/home/laurens/projects/lynx/components/lynxathome/lah-node/venv/lib/python3.5/site-packages/aiocoap/protocol.py", line 293, in find_remote_and_interface
    if await ri.fill_or_recognize_remote(message):
  File "/home/laurens/projects/lynx/components/lynxathome/lah-node/venv/lib/python3.5/site-packages/aiocoap/tokenmanager.py", line 179, in fill_or_recognize_remote
    return await self.token_interface.fill_or_recognize_remote(message)
  File "/home/laurens/projects/lynx/components/lynxathome/lah-node/venv/lib/python3.5/site-packages/aiocoap/transports/tcp.py", line 469, in fill_or_recognize_remote
    if message.requested_scheme == self._scheme:
  File "/home/laurens/projects/lynx/components/lynxathome/lah-node/venv/lib/python3.5/site-packages/aiocoap/message.py", line 539, in requested_scheme
    return self.request.requested_scheme
AttributeError: 'Message' object has no attribute 'request'

Replacing Code.PING with CODE.GET works, but without expected result obviously. I don't understand how it's possible that a property request is expected or can be expected on a Message class.

I'm using the current master.

What am I doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions