-
Notifications
You must be signed in to change notification settings - Fork 406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client is not registering on Server for Leshan version "2.0.0-M14" #1596
Comments
I was able to solve client registration issue with below code:
Setting clientAddress to CaliforniumClientEndpointsProvider was my mistake: "endpointsBuilder.setClientAddress(InetAddress.getLocalHost());" So now only issue persist is of Leshan WebServer UI is not working at http://localhost:8080
Any suggestions / help would be great. Thank you for your attention! |
I looked at your server code and it should rather looks like : // create provider
final CaliforniumServerEndpointsProvider californiumServerEndpointsProvider = new CaliforniumServerEndpointsProvider.Builder(
new CoapServerProtocolProvider()) //
.setConfiguration(config -> config.set(CoapConfig.PROTOCOL_STAGE_THREAD_COUNT, 4))
.addEndpoint("coap://localhost:5683") //
// OR
// .addEndpoint(new InetSocketAddress("localhost", 5683), Protocol.COAP) //
.build();
// create server
LeshanServerBuilder builder = new LeshanServerBuilder();
// builder.setRegistrationIdProvider(new RandomStringRegistrationIdProvider()); // not needed used by default
builder.setEndpointsProviders(californiumServerEndpointsProvider);
LeshanServer server = builder.build();
// start it
server.start();
// listen for registration
server.getRegistrationService().addListener(new RegistrationListener() {
@Override
public void registered(Registration registration, Registration previousReg,
Collection<Observation> previousObservations) {
System.out.println("Registered client: " + registration.getEndpoint());
}
// Other override methods
});
// All the jetty code is useless OR it missed your own code to add `Servlet` to jetty.
Leshan is a library, there is no web server UI. See FAQ to better understand : https://github.com/eclipse-leshan/leshan/wiki/F.A.Q.#what-is-leshan-and-how-should-i-use-it- |
Thank you very much @sbernard31. Now it's clear to me and thanks for the code. I will change my code accordingly. Satisfied with the answer and good to close this issue. Thanks again... |
You're welcome. |
Question
Hello Team.
I am new to Leshan and looking for help to start with Leshan. I am trying to implement Leshan Server and Client in my project.
I was following the Github documentation and have implemented Leshan Server and Client with version "1.5.0" which is working fine with each other.
When I tried implementation with version “2.0.0-M14”, my Leshan Client was not able to register onto the server. Whereas, my Leshan Server is working well with the Leshan-Client-Demo JAR file provided in the docs. I am able to register and able to send the data to server using command line.
Leshan Server Code is below:
There is only issue with server is, I am not able to access web-server to see the UI at http://localhost:8080. I fails with below error:
HTTP ERROR 404 Not Found
Leshan Client Code is below:
The Leshan Client with above code not able to register itself onto the server. It fails with below error:
Also, "client.getRegisteredServers()" always returns empty map.
Thank you for your attention!
The text was updated successfully, but these errors were encountered: