woopsa-protocol / woopsa Goto Github PK
View Code? Open in Web Editor NEWWoopsa is the first fully open-source object-oriented protocol for automation and the Internet of Things
Home Page: http://www.woopsa.org
License: MIT License
Woopsa is the first fully open-source object-oriented protocol for automation and the Internet of Things
Home Page: http://www.woopsa.org
License: MIT License
Currently, calling void WoopsaServer.ClearCache()
doesn't work as expected when combined with a WoopsaObjectAdapter
. It successfully clears the server's path cache, but the WoopsaObjectAdapter
is not rebuilt like it should.
public class SmokeDetector
{
public bool SmokeDetected { get; private set; }
public int Battery { get; private set; }
public SmokeDetector(int battery){
Battery = battery;
}
}
public class VentilationSystem
{
public VentilationSystem()
{
SmokeDetector = new SmokeDetector(100);
}
public bool Power { get; private set; }
public SmokeDetector SmokeDetector { get; set; }
}
...
VentilationSystem system = new VentilationSystem();
WoopsaServer server = new WoopsaServer(system);
...
system.SmokeDetector = new SmokeDetector(50); // Changing the SmokeDetector
server.ClearCache();
// Unfortunately, /woopsa/read/SmokeDetector/Battery still
// gives out 100 instead of 50 as expected, because the
// WoopsaObjectAdapter still refers to the previous object
To fix this issue, public void WoopsaObjectAdapter.ClearCache()
needs to be updated to empty its inner list of Items.
Currently, the C# WebServer does not support multipart/form-data
-encoded POST requests. This makes it impossible for clients to send files to servers.
Supporting this method of POST requests should be optional as it requires some additional security checks (what happens if a user tries to upload a 1TB file? etc) and creation of additional Streams.
The HTTPRequest
class could then contain a Files
array of Stream
s allowing the programmer to act on these files, for example saving them to disk or parsing them on-the-fly.
As of today, authentication in the Woopsa protocol does not work when using the JavaScript client (browser) library, if the server resides on a different domain-name than the page making the requests.
This is a situation which can appear when HTML pages are making requests to "independent" Woopsa servers.
The problem seems to come from the rather recent CORS specification (see this StackOverflow issue for some discussion on the subject)
The problem did not appear during earlier development as there was a bug in Chrome that made it not respect the CORS specifications 100%.
When one wishes to make a cross-domain HTTP request from a JavaScript page, there are some security implications. To remedy this, the W3C has come up with a "great" solution that is CORS: Cross-origin resource sharing combined with pre-flight headers
What this means is that any XMLHTTPRequest (AJAX) request from a page may not be made to a server on a different domain directly. Instead, the browser needs to know if this request is "allowed". It does this by making an HTTP OPTIONS
request before making the actual GET
or POST
request.
If a server accepts cross-domain requests, it should reply with something like
Access-Control-Allow-Origin: http://foo.com
Access-Control-Allow-Methods: GET, POST
But it should not execute any action. If this reply satisfies the browser, then it will make the actual request.
This doesn't seem like much of a problem in most cases, as current Woopsa server implementations treat OPTIONS
requests like any others and actually already send these Access-Control-Allow-*
headers in every situation. However, this could be a problem with the Invoke Woopsa action, since requests will be made twice.
The problem becomes really problematic when we add Authentication to a Woopsa server. This is because the CORS specification explicitly forbids user credentials to be sent in the OPTIONS
request. Thus, Woopsa servers won't see any credentials and will just reply with HTTP error 401: Authentication Required
.
To solve this rather complicated problem, Woopsa servers need to be modified to handle OPTIONS
requests in a clean way. Be careful, however, as this might have some high-level implications:
OPTIONS
request is received by a server, it should send the currently-sent HTTP headers (Access-Control-Allow-Origin, etc.)To get around this problem, use the content-serving abilities of the different Woopsa server implementations to host JavaScript and HTML. This will make it so HTML+JS is hosted on the same domain as the Woopsa server, and will avoid this cross-domain CORS nonsense.
Currently, WoopsaEmbedded uses WoopsaInt16 everywhere, including the content-length. This limits pages served through Woopsa to 32kB, which is not enough for serving scripts like jQuery.
It's necessary to work with WoopsaInt32's or find another mechanism that will allow to overcome this limit.
Now a read looks like:
GET /woopsa/read/Temperature
which returns:
{"Value":24.2,"Type":"Integer","TimeStamp":"Sat Jan 02 00:00:00 GMT+05:30 2010"}
I suggest to add a simplier read request which would returns only the raw value instead of the full JSON payload.
This read, called here rawread, would look like that instead:
GET /woopsa/rawread/Temperature
which would simply returns:
24.2
In my opinion, this could be valuable in two main aspects:
This simplier request could be very useful for embedded systems with limited resources as well as for even quicker use of the web REST woopsa API for some simple use cases. Moreover, a raw value beeing also considered as a JSON object, this could still be used with a JSON parser as well.
It would be nice to have option to define dynamic property. By dynamic I understand property that is resolved during program execution. Lets say I have server for PLC and I want to serve I/O. Instead of defining each I/O as bool, byte, word i would like to have one route lets say /io and based on request resolve it to proper value.
Hi, am interested in using Woopsa node server to bridge to OPC UA. The homepage has the tantalising statement: "Because Woopsa shares so many concepts with OPC-UA, you can also use it as a gateway server to connect your webapps to OPC-UA servers."
Is there any more information about how to do this? I'm happy to write some bridging code, but it's not clear how to get started.
Thanks
How can I represent "ARRAY [1..10] OF WORD" as Woopsa value? Its one of basic PLC types.
Problem description
It seems the Subscribe method from WoopsaClientSubscriptionChannel does not handle backslash in path. It doesn't throw an exception but it doesn't work at all.
It can be confusing because the output given by oMachine use backslash instead of slash and the Read method supports backslash as well.
Current behaviour:
client.SubscriptionChannel.Subscribe(@"Thermostat\SetPoint", (e, a) =>
{
...
});
=> KO
client.SubscriptionChannel.Subscribe("Thermostat/SetPoint", (e, a) =>
{
...
});
=> OK
var point = client.ClientProtocol.Read(@"Thermostat\SetPoint")
=> OK
Expected behaviour
Subscribe method should handle backslash in the path:
client.SubscriptionChannel.Subscribe(@"Thermostat\SetPoint", (e, a) =>
{
...
});
=> OK
On libraries.io an early woopsa release an implementation for Beckhoff PLC was mentioned.
Has this implementation been dropped?
Hi,
I updated, with nuGet, from ver like 1.1.9 to 1.1.11 and some references are now missing. Please let me know me the new ones.
Thank you.
I am running the DotNet WoopsaDemoServer. I type "AUTH [enter]". Then I write "http://127.0.0.1:54004/woopsa/read/Temperature" in Google Chrome. I get the response "{"Value":24.2,"Type":"Real"}". I expect that I should not get access to this data because I did not provide authentication with username and password.
After that I typed "noauth [enter]" and tried again, the Google Chrome showed a Sign In popup window.
Then I tried to disable the authentication but couldn't. I also tried to open Internet Explorer 11 every time I type auth or noauth, but the popup shows up every time.
Is there some sort of long delay before the authentication is enabled or disabled?
This is repeatable: When I start the program, the server requires notification immediately only when I type "auth [enter] noauth [enter]". Why? But I cannot turn the authentication off. I am using the latest Woopsa 1.2.
WoopsaValue check DateTime with invariant culture in WoopsaValue.cs
[...]
case WoopsaValueType.DateTime:
DateTime.Parse(text, CultureInfo.InvariantCulture);
[...]
and after convert the string without any culture in WoopsaExtensions.cs
[...]
DateTime result;
if (DateTime.TryParse(value.AsText, null, DateTimeStyles.RoundtripKind, out result))
return result;
[...]
This leads to erroneous behavior according to the cultures of the PC
Hello,
Thank you for your awesome work.
Could you explain how to implement the MultiRequest method on a javascript client ?
Is it just by using:
client.MultiRequest(jsonarray, ....
Thank you in advance,
When I am running the DotNet WoopsaDemoServer and I write "http://localhost:54004/woopsa/read/Temperature" in the Google Chrome browser (Latest Version 89.0.4389.72 (Official Build) (64-bit)), I get "This site can’t provide a secure connection localhost sent an invalid response. Try running Windows Network Diagnostics. ERR_SSL_PROTOCOL_ERROR".
This happens because the browser automatically changes http:// to https:// when I press enter. It works well if I write "http://127.0.0.1:54004/woopsa/read/Temperature".
You might put a warning in your Quick Start Guide.
This is not a problem in Internet Explorer 11. I haven't checked any other browsers.
A Java implementation would be great.
I use WoopsaClient from a WPF application and when I have shutdown my last window there are still woopsa threads running. This only happens when I have registered for subscription using the method or the Change event on the WoopsaProperty. I am disposing the WoopsaClient.
Hi do you have plans for a c++ implementation of woopsa?
Currently, the CheckCache
delegate can be used on the WoopsaServer
to selectively choose which paths are cached or not.
However, in cases where one uses the WoopsaObjectAdapter
(in the default WoopsaServer
constructor for example), there is no way to selectively cache (or not) certain objects. This makes working with IEnumerable
s a bit complicated, as the whole cache needs to be cleared.
Hi,
How can I send a file from Client to Server ?
I try to send my file as a string, but the request buffer seems to be too small, is it limited to 10ko ?
So I try to upload my file using standard webclient.uploadfile but the server doesn't recognized this command.
How can I proceed to send a large file ?
Thank for the help,
Fabien
Hello,
in my model I have some generic collections (List, Dictionary<TKey, TValue>, etc).
What are the best practices for mapping collections of objects?
Is it possible to have a simple example in which a collection is mapped and how to map and access its elements?
Thanks in advance
Here is some know issues on .net core target :
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.