emqx / emqx-coap

EMQX CoAP Gateway
https://www.emqx.com
Apache License 2.0
61 stars 34 forks source link

Can i use other ways to validate the coap client ? #53

Closed EzPluto closed 6 years ago

EzPluto commented 7 years ago

for exp,use emq-auth-http model to check the clientId,username and password just like mqtt ?

grutabow commented 7 years ago

Sure, you are right.

EzPluto commented 7 years ago

@grutabow

use libcoap to public or subscribe topic ,return 4.04

libcoap/examples/coap-client -m get -s 10  "coap://myhost:5684/mqtt/readtopic?c=client_test&u=username_test&p=secret_test"

without topic

libcoap/examples/coap-client -m get -s 10  "coap://myhost:5684/mqtt?c=client_test&u=username_test&p=secret_test"

v:1 t:CON c:GET i:736b {} [ Observe:1, Uri-Port:5684, Uri-Path:mqtt, Uri-Query:c=client_test, Uri-Query:u=username_test ]

what happened?

grutabow commented 7 years ago

5684 is a secure port which requires DTLS, and not sure libcoap supports DTLS already or not. Please send data to port 5683.

EzPluto commented 7 years ago

my docker file

emqnode1: 
    image: emqttd-docker-v2.3-beta.4
    hostname: emqnode1
    mem_limit: 512M
    container_name: emqnode1
    ports: 
      - "1884:1883"
      - "18084:18083"
      - "5684:5683/udp"
emqnode2: 
    image: emqttd-docker-v2.3-beta.4
    hostname: emqnode2
    mem_limit: 512M
    container_name: emqnode2
    links: 
      - emqnode1
    ports: 
      - "1885:1883"
      - "18085:18083"
      - "5685:5683/udp"
emqnode3: 
    image: emqttd-docker-v2.3-beta.4
    hostname: emqnode3
    mem_limit: 512M
    container_name: emqnode3
    links: 
      - emqnode1
    ports: 
      - "1886:1883"
      - "18086:18083"
      - "5686:5683/udp"

it`s same as 5683

@grutabow

If topic contains special characters like '/','+','#' , shoud i use urlencode to percent-encode? And what about clientId,username,password , how to handle those special characters.

grutabow commented 7 years ago

Would you please post the crash and error logs which could help the 4.04 problem?

grutabow commented 7 years ago

If there are special characters in topic, it should be percent-encoded as you mentioned. There should be no special characters inside clientId, username and password now. Maybe we can support it in a future version.

grutabow commented 6 years ago

libcoap/coap-client is able to percent-decode special characters in clientid, username and password since it is query in a URI. It is recommended not to use special characters in clientid, username and password.