chrysn/aiocoap

creation of hundreds of resources error

Closed this issue · 4 comments

I used this code to create hundreds of resources:

 for indexFloor in range(1,4):
    for indexOffice in range(1,10):
        # resources creation
        for indexLum in range(1,3):
            context = await Context.create_client_context()
            payload = b'</3311/0/5850/>;rt="ipso.lt.on";if="core.a";ct=40' 
            request = Message(code=POST, payload=payload, uri="coap://localhost/resourcedirectory/?ep=lm00"+str(indexLum)+"&d=bldg1.fl"+str(indexFloor)+".off"+str(indexOffice))
            request.opt.content_format = 40
            try:
                await context.request(request).response
            except Exception as e:
                 print(e)

I got the following error after running this command:
aiocoap-client --method GET coap://localhost/endpoint-lookup/

Traceback (most recent call last):
  File "/home/aiocoap/.local/bin/aiocoap-client", line 8, in <module>
    sys.exit(sync_main())
  File "/home/aiocoap/.local/lib/python3.8/site-packages/aiocoap/cli/client.py", line 361, in sync_main
    asyncio.get_event_loop().run_until_complete(single_request(args))
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/home/aiocoap/.local/lib/python3.8/site-packages/aiocoap/cli/client.py", line 301, in single_request
    present(response_data, options)
  File "/home/aiocoap/.local/lib/python3.8/site-packages/aiocoap/cli/client.py", line 123, in present
    prettyprinted = pretty_print(message)
  File "/home/aiocoap/.local/lib/python3.8/site-packages/aiocoap/util/prettyprint.py", line 69, in pretty_print
    parsed = linkformat.link_header.parse(message.payload.decode('utf8'))
  File "/home/aiocoap/.local/lib/python3.8/site-packages/link_header.py", line 87, in parse
    raise ParseException("link_header.parse() failed near %s", repr(scanner.buf))
link_header.ParseException: ('link_header.parse() failed near %s', '\'="\'')

Any help would be appreciated.

For some reasons I'm just investigating, blockwise transfer doesn't kick in here -- and the the message is cut short, and the protocol violated, and above all the pretty-printer fails. This is a combination of failures in the library, I'll try to pick them off one by one.

Just a brief update: First issue ("Pretty-printer raises ugly message") is fixed now in c5c79f4.

The rest seems to be due to the RD also running a proxy (to implement a proposal for enhanced reachability); the reverse proxying code that is traversed for this doesn't handle block-wise requests correctly.

Should be resolved with 3849d9c, please reopen if any of the described issues remain with current master branch.

It works now like a charm (not hundreds but thousands).
Thank you chrysn so much.