Code Monkey home page Code Monkey logo

Comments (17)

eugene-nikolaev avatar eugene-nikolaev commented on August 15, 2024

Faced with the same issue, used

 client.useNONs();

I will look through code why Type.NON is ignored.

from californium.

wiinguyen avatar wiinguyen commented on August 15, 2024

Hi Eugene,

client.useNONs() seems to work.

Thanks,

James

On Wed, Jul 20, 2016 at 4:36 PM, Eugene Nikolaev [email protected]
wrote:

Faced with the same issue, used

client.useNONs();

I will look through code why Type.NON is ignored.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#75 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADkRp3McgjqeHWWSIPIe4ORZxoNctZ5sks5qXjJsgaJpZM4JQvg1
.

James Nguyen
Email: [email protected]

from californium.

eugene-nikolaev avatar eugene-nikolaev commented on August 15, 2024

A pull request has been added.

from californium.

wiinguyen avatar wiinguyen commented on August 15, 2024

I just did a git pull. Nothing has been updated.

On Wed, Jul 20, 2016 at 7:09 PM, Eugene Nikolaev [email protected]
wrote:

A pull request has been added.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#75 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADkRp6w7X3vpjRyF3iR75uXVFgErPIHZks5qXlZQgaJpZM4JQvg1
.

James Nguyen
Email: [email protected]

from californium.

eugene-nikolaev avatar eugene-nikolaev commented on August 15, 2024

from californium.

sophokles73 avatar sophokles73 commented on August 15, 2024

CoapClient's send() methods indeed set the request type to the client's configured default type (set via CoapClient.useNONs() or CoapClient.useCONs() as you already figured out). If you want more control over the specifics of the request you should use CoapClient.advanced(Request) for sending synchronously or CoapClient.advanced(Request, CoapHandler) for sending asynchronously instead.
These methods only set the passed in request's URI to the target URI set for the client.
I currently tend to therefore close this issue and the related PR unless you still feel that Californium should behave differently ...

from californium.

eugene-nikolaev avatar eugene-nikolaev commented on August 15, 2024

Thanks for reply!

Not sure if I 100% understand the points, but in my case, CoapCliient#advanced uses CoapClient#asynchronous (or synchronous) which uses CoapClient#send.
So Request#type is never applied and it looks strange in the code:

        CoapClient client = getClient(path);
        client.useNONs();
        Request request = new Request(code, Type.CON);
        ...
        client.advanced(request);
        // Actually the request will be CON

from californium.

wiinguyen avatar wiinguyen commented on August 15, 2024

Yes, I manually set the request and used client.advance() method, but the server treated the non-confirmable message as if it was a confirmable message.

On Jul 21, 2016, at 9:08 AM, Kai Hudalla [email protected] wrote:

CoapClient's send() methods indeed set the request type to the client's configured default type (set via CoapClient.useNONs() or CoapClient.useCONs() as you already figured out). If you want more control over the specifics of the request you should use CoapClient.advanced(Request) for sending synchronously or CoapClient.advanced(Request, CoapHandler) for sending asynchronously instead.
These methods only set the passed in request's URI to the target URI set for the client.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

from californium.

eugene-nikolaev avatar eugene-nikolaev commented on August 15, 2024

I could bear with it but it is not so convenient if client operations are incapsulated like this:

    void nonPut(String path, byte[] payload)  {
        performRequest(path, payload, Code.PUT, Type.NON);
    }

    void conPut(String path, byte[] payload)  {
        performRequest(path, payload, Code.PUT, Type.CON);
    }

    ...

So somewhere in the performRequest I have to have an if with useCONs/useNONs in clauses.
Though of course it's minor.
But I think such issues would be created multiple times because of confusion.

from californium.

wiinguyen avatar wiinguyen commented on August 15, 2024

Indeed, it is not.

I'd rather users more control of Request.

On Jul 21, 2016, at 10:07 AM, Eugene Nikolaev [email protected] wrote:

I could bear with it but it is not so convenient if client operations are incapsulated like this:

void nonPut(String path, byte[] payload)  {
    performRequest(path, payload, Code.PUT, Type.NON);
}

void conPut(String path, byte[] payload)  {
    performRequest(path, payload, Code.PUT, Type.CON);
}

...


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

from californium.

sophokles73 avatar sophokles73 commented on August 15, 2024

@evgeniynickolaev,

after taking another look at the code, I guess you're right. the advanced() methods also delegate to the same send() method :-(
I guess we should move the request.setType() from send() to the convenience methods (post(), put(), get() etc) then. This way, client code can use the advanced() methods for sending a request that it has configured manually whereas the convenience methods can be used in the established way, e.g. by less experienced users. AFAIK we should also make sure that the target URI can be set explicitly when using advanced().

What do you think?

from californium.

eugene-nikolaev avatar eugene-nikolaev commented on August 15, 2024

@sophokles73 ,

Oh, yes, I see your point, it will be great and will solve the issue.

But CoapClient#send should anyway set the type if Request#type is null otherwise we can break some legacy code.

May I make another pull request?

from californium.

sophokles73 avatar sophokles73 commented on August 15, 2024

That's true, however, this issue already came up in another context (TCP support) and we thought that it seems strange that we even allow for a Message being created without a type being set/supplied. I think we should tackle the issue at its source and set the type to e.g. CON by default in the Message constructor ...

from californium.

eugene-nikolaev avatar eugene-nikolaev commented on August 15, 2024

So I should also add CON by default to the Message. OK, I like it.

from californium.

wiinguyen avatar wiinguyen commented on August 15, 2024

That'll be helpful. :)

On Jul 21, 2016, at 12:01 PM, Eugene Nikolaev [email protected] wrote:

So I should also add CON by default to the Message. OK, I like it.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

from californium.

eugene-nikolaev avatar eugene-nikolaev commented on August 15, 2024

I've added a new pull request

#78

from californium.

eugene-nikolaev avatar eugene-nikolaev commented on August 15, 2024

I've added a pull request with the review comments applied.

#79

@sophokles73, could you please revise it?

from californium.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.