-
Notifications
You must be signed in to change notification settings - Fork 81
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
CoAP ClientFactory #741
Comments
I did test an updated code with passing CoapServer (attached the sample) and I now see another issue? @JKRhb do you know "why" getSocket() is not a function?
|
Hmm, I tried to reproduce the issue but didn't encounter any problems. Passing the server like this works fine: Servient = require("@node-wot/core").Servient;
CoapClientFactory = require("@node-wot/binding-coap").CoapClientFactory;
CoapServer = require("@node-wot/binding-coap").CoapServer;
Helpers = require("@node-wot/core").Helpers;
// create Servient and add CoAP binding
let servient = new Servient();
const server = new CoapServer();
servient.addServer(server);
servient.addClientFactory(new CoapClientFactory(server));
let wotHelper = new Helpers(servient);
wotHelper
.fetch("coap://plugfest.thingweb.io:5683/testthing")
.then(async (td) => {
// using await for serial execution (note 'async' in then() of fetch())
try {
const WoT = await servient.start();
const thing = await WoT.consume(td);
// read property
const read1 = await thing.readProperty("string");
console.log("string value is: ", await read1.value());
} catch (err) {
console.error("Script error:", err);
}
})
.catch((err) => {
console.error("Fetch error:", err);
}); Also, the server argument is in fact nullable at the moment? Or am I missing something? Edit: Just noticed that I was looking in the wrong place, in the client factory the server is in fact non-nullable which shouldn't be the case, I suppose. |
I just found where the non-nullable server argument was introduced: 0b2510a |
I think this issue should be fixed by now, right? |
@relu91 @danielpeintner
I haven't really tested but I was exploring the COAP example in readme and saw there
servient.addClientFactory(new CoapClientFactory(null));
How is this legit if it passes null as CoapServer, which was working before but in v8 the field is not nullable anymore?
Originally posted by @fatadel in #721 (comment)
The text was updated successfully, but these errors were encountered: