【问题标题】:aiocoap fetch method not allowed不允许使用 aiocoap 获取方法
【发布时间】:2021-04-11 18:14:38
【问题描述】:

python3 -m aiocoap.cli.defaults 命令的输出是:

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

我作为服务器 aiocoap-rd 运行。 然后我运行以下命令来运行 RD 客户端:

aiocoap-client --method FETCH --content-format 40 --payload '' --accept 40 coap://localhost/resource-lookup/?rt=temperature-c

我收到此错误:

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!'")

GET 方法工作正常。

有什么帮助吗?

【问题讨论】:

    标签: python fetch coap


    【解决方案1】:

    没有为资源目录的资源定义 FETCH 方法,因此没有在 RD 服务器上实现。

    一般来说,只有在有一些迹象(通常来自正在使用的高级协议,或者具体地来自较早的浏览步骤,例如通过某种表单机制)时,才应该尝试 FETCH可用;该来源还将告诉您在 FETCH 请求中发送什么(因为它应该有一个重要的有效负载,否则它也可能是一个 GET)。

    【讨论】:

      猜你喜欢
      • 2014-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多