eclipse-leshan / leshan

Java Library for LWM2M
https://www.eclipse.org/leshan/
BSD 3-Clause "New" or "Revised" License
652 stars 407 forks source link

unable to connect leshan client to leshan Bootstrap server #635

Closed sivavijay13 closed 5 years ago

sivavijay13 commented 5 years ago

I am trying to connect leshan demo client to https://leshan.eclipse.org/bs/ using below command but keep getting below message

Command(tried both hex & ascii value): java -jar leshan-client-demo.jar -u leshan.eclipse.org:5784 -b -i 866971030000710 -p 1234 -n vin2client -lp 49665 Error Message:

2019-01-09 18:15:35,837 WARN RegistrationEngine - Unable to send Bootstrap request : handshake flight 1 timeout!

sbernard31 commented 5 years ago

I look at https://leshan.eclipse.org/bs and search for your endpoint name and I didn't find the same credentials.

coaps://leshan.eclipse.org:5784
security mode : PSK
Id :  866971030000710
secret :  31323334

Just tested with it and it works for me :

2019-01-11 14:31:24,204 INFO CaliforniumEndpointsManager - New endpoint created for server coaps://5.39.83.206:5784 at coaps://0.0.0.0:35075
2019-01-11 14:31:24,479 INFO RegistrationEngine - Bootstrap started
2019-01-11 14:31:24,694 INFO RegistrationEngine - Bootstrap finished Bootstrap Server [uri=coaps://leshan.eclipse.org:5784].
2019-01-11 14:31:24,708 INFO CaliforniumEndpointsManager - New endpoint created for server coap://5.39.83.206:5683 at coap://0.0.0.0:56175
2019-01-11 14:31:24,710 INFO RegistrationEngine - Trying to register to coap://5.39.83.206:5683 ...
2019-01-11 14:31:24,756 ERROR RegistrationEngine - Registration failed: FORBIDDEN .

Device does succeed to register to leshan.eclipse.org because LWM2M Server config credential does not match with leshan.eclipse.org credentials setting : https://leshan.eclipse.org/#/security. (Bootstrap say unsecured connection and lwm2m server expect PSK for "vin2client" endpoint name)

sivavijay13 commented 5 years ago

Hi,

Today I had created below details in Step1: https://leshan.eclipse.org/bs/

Client Endpoint | LWM2M Bootstrap Server |
vinClient4 | coaps://leshan.eclipse.org:5784security mode : PSKId : 12345 secret : 31323334

LWM2M Server coaps://leshan.eclipse.org:5684security mode : PSKId : 12345 secret : 31323334

Step2: In Gateway created below https://leshan.eclipse.org/#/security

Client Endpoint | Security Mode | Security Information

vinClient4 | Pre-Shared Key | Identity : 12345Key : 31323334

Step3:

Using below command started the client java -jar leshan-client-demo-1.0.0-M10-jar-with-dependencies.jar -b -u leshan.eclipse.org:5784 -n vinClient4 -i 12345 -p 31323334

Step4:

Getting below exception. 2019-01-17 11:34:21,694 INFO LeshanClientDemo - Press 'w','a','s','d' to change reported Location (-18.0,-29.0). 2019-01-17 11:34:21,694 INFO LeshanClient - Starting Leshan client ... 2019-01-17 11:34:21,694 INFO LeshanClient - Leshan client[endpoint:vinClient4] started. 2019-01-17 11:34:21,694 INFO RegistrationEngine - Trying to start bootstrap session to coaps://leshan.eclipse.org:5784 ... 2019-01-17 11:34:22,056 INFO CaliforniumEndpointsManager - New endpoint created for server coaps://5.39.83.206:5784 at coaps://0.0.0.0:57718 2019-01-17 11:34:53,189 WARN RegistrationEngine - Unable to send Bootstrap request : handshake flight 1 timeout!

I am unable to narrow down what exactly I was missing. Please let me know. Whether my steps are in order sequence.

sbernard31 commented 5 years ago

Just tested on my side with master :

~/g/leshan ❯❯❯ java -jar leshan-client-demo/target/leshan-client-demo-1.0.0-SNAPSHOT-jar-with-dependencies.jar -b -u leshan.eclipse.org:5784 -n vinClient4 -i 12345 -p 31323334
2019-01-17 14:23:36,311 INFO LeshanClientDemo - Press 'w','a','s','d' to change reported Location (50.0,137.0).
2019-01-17 14:23:36,312 INFO LeshanClient - Starting Leshan client ...
2019-01-17 14:23:36,316 INFO LeshanClient - Leshan client[endpoint:vinClient4] started.
2019-01-17 14:23:36,319 INFO RegistrationEngine - Trying to start bootstrap session to coaps://leshan.eclipse.org:5784 ...
2019-01-17 14:23:36,365 INFO CaliforniumEndpointsManager - New endpoint created for server coaps://5.39.83.206:5784 at coaps://0.0.0.0:44220
2019-01-17 14:23:36,679 INFO RegistrationEngine - Bootstrap started
2019-01-17 14:23:36,866 INFO RegistrationEngine - Bootstrap finished Bootstrap Server [uri=coaps://leshan.eclipse.org:5784].
2019-01-17 14:23:36,879 INFO CaliforniumEndpointsManager - New endpoint created for server coaps://5.39.83.206:5684 at coaps://0.0.0.0:45074
2019-01-17 14:23:36,880 INFO RegistrationEngine - Trying to register to coaps://5.39.83.206:5684 ...
2019-01-17 14:23:37,033 INFO RegistrationEngine - Registered with location '/rd/Z6UsDz5Wfd'.
2019-01-17 14:23:37,034 INFO RegistrationEngine - Next registration update to coaps://5.39.83.206:5684 in 18s...

It works for me.

Also tested with M10 version, it works for me too.

I suppose this is network issue on your side. By the way the log says that the DTLS handshake timeout on flight 1. So this means thats you never receive a response from the server even at DTLS layer which would confirm a network issue.

You could use wireshark to know what happen at network layer.

sbernard31 commented 5 years ago

Should we close this issue ?