chrysn/aiocoap

Fetch method 'Not Allowed'

Closed this issue · 12 comments

The output of the command python3 -m aiocoap.cli.defaults is :
Python version: 3.8.5 (default, Jan 27 2021, 15:41:15)
[GCC 9.3.0]
aiocoap version: 0.4.1
Modules missing for subsystems:
dtls: missing DTLSSocket
oscore: everything there
linkheader: everything there
prettyprint: everything there
Python platform: linux
Default server transports: oscore:tcpserver:tcpclient:tlsserver:tlsclient:ws:udp6
Selected server transports: oscore:tcpserver:tcpclient:tlsserver:tlsclient:ws:udp6
Default client transports: oscore:tcpclient:tlsclient:ws:udp6
Selected client transports: oscore:tcpclient:tlsclient:ws:udp6
SO_REUSEPORT available (default, selected): True, True

I run as server aiocoap-rd.
Then i run the following command :
aiocoap-client --method FETCH --content-format 40 --payload '' --accept 40 coap://localhost/resource-lookup/?rt=temperature-c

I get this error :
4.05 Method Not Allowed 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 304, in single_request present(response_data, options, file=sys.stderr) 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', "'Error: Method not allowed!'")

The GET method works fine.

Any help ?

A appreciate your immediate support 👍

For example if i run this command:
aiocoap-client --method GET coap://localhost/resource-lookup/?rt=temperature-c

I got two resources:
<coap://127.0.0.1:53082/sensors/temp>; rt=temperature-c; secure=1; anchor="coap://127.0.0.1:53082", <coap://127.0.0.1:44501/sensors/temp>; rt=temperature-c; secure=0; anchor="coap://127.0.0.1:44501"

The secure attribute indicates if the sensor is secure or not.
In my case, i want to perform a fetch method to get only the secure temp sensors (secure=1)

The recommendation provided to me is to send the request parameters in the payload of FETCH method:
payload={secure=1}

Is there a way to perform this using aiocoap FETCH not the GET method ?
For example :
aiocoap-client --method FETCH --payload 'secure=1' coap://localhost/resource-lookup/?rt=temperature-c

Thanks in advance.

Actually, the recommendation (suggestion) is issued from a master thesis work ;)

payload={secure=1}

I write this as illustration example only.

Sure one can alter it that way,

How can i alter it using application/link-format and FETCH method ?

Could you just point me to the paper?

You can find the suggested work in this link

I would to reproduce this work but using aiocoap.

Can i have your email please so i can reach you.

Thank you so much.
I appreciate your help.
I will follow your advises very firmly.

Best.

I will do my best.