coapjs / coap-cli

A command line interface for CoAP built on node-coap
Other
75 stars 30 forks source link

Problems with sending coap ipv6 messages in version 0.6.0+ #56

Closed Chenamob closed 3 years ago

Chenamob commented 4 years ago

Description

problems with sending standard (not dtls) coap ipv6 messages to Contiki-NG node via coap-cli version 0.6.0 and upper

Steps to Reproduce

Expected behavior

Actual behavior

debian@beaglebone:~$ coap get coap://[fd00::212:4b00:1cbc:1d51]/node/dtls -p 11223344
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: getaddrinfo ENOTFOUND [fd00::212:4b00:1cbc:1d51]
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)  

(with coap-cli version 0.5.1 all good - remote node successfully receive the message)

Affected Versions

0.6.0, 0.6.1, 0.7.0

Chenamob commented 4 years ago

for node 12.15.0

debian@beaglebone:~$ sudo coap get coap://[fd00::212:4b00:1cbc:1d51]/node/dtls -p 11223344
[sudo] password for debian:
events.js:200
      throw er; // Unhandled 'error' event
      ^

Error: getaddrinfo ENOTFOUND [fd00::212:4b00:1cbc:1d51]
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:60:26)
Emitted 'error' event on OutgoingMessage instance at:
    at RetrySend.emit (events.js:223:5)
    at /usr/lib/node_modules/coap-cli/node_modules/coap/lib/retry_send.js:49:28
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: 'ENOTFOUND',
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: '[fd00::212:4b00:1cbc:1d51]'
}
debian@beaglebone:~$ node -v
v12.15.0
Citrullin commented 4 years ago

When creating a workaround in /etc/hosts for #73, I end up in this error as well.

playhard21 commented 3 years ago

Did anyone slove this even I am having same issue. I can get resources with aiocaop but not with coap. I am using version 0.7.1 Thank you

JKRhb commented 3 years ago

To give you a brief update on this issue: The problem arises from the URL constructor that is currently being used. Here, the square brackets are not being removed from literal IP addresses. Node's net module, which is being used for determining the address type, however, only accepts IPv6 addresses without the square brackets. Therefore, some manual adjustments are required to get this to work. I will soon try to provide a fix for this (I already implemented a solution for this problem in node-coap).