Updating c8y_RequiredAvailability using MQTT Templates - cumulocity

We have MQTT devices that can change how often they send data, so we want to be able to have the device change its c8y_RequiredAvailability value.
I have tried using static template 117, but that only works for the initial creation, not for updating.
I am currently trying to create a SmartREST Template but I keep getting the following error:
50,,Error of type: ClassCastException with message: java.math.BigInteger cannot be cast to java.lang.Long
when sending the following publish:
800,MQTT_FX_Client3,8
Any ideas what I am missing?

Related

CefSharp.BrowserSubProcess.Core WCF pipe failure

Our application is using CefSharp version 73.1.130. The issue only occurs on a small number of internal workstations within our organization. Worth noting, we are also seeing the same error with CefSharp version 92. Another strange thing is that it the issue is consistent, but only when the web apps are launched through certain navigations. Other navigations work consistently for these users.
We use RegisterJsObject to register a javascript object with browser. If I understand correctly, asynchronous binding is preferred moving forward.
The issue presents as strange/unexpected behavior in the hosted web application due to failure to retrieve context from the host WinForms application. The behavior would suggest a failure to register/bind the js object with the RegisterJsObject method. However, that method is not throwing an exception.
Enabled Cef logging showed the following error:
ERROR:JavascriptRootObjectWrapper.cpp(34)] IBrowserProcess is null, unable to bind object
After looking into the code, it appears the location that the value pointed to by "IBrowserProcess" is set is in WcfEnabledSubProcess::OnBrowserCreated (https://github.com/cefsharp/CefSharp/blob/cefsharp/73/CefSharp.BrowserSubprocess.Core/WcfEnabledSubProcess.cpp). I was able to build CefSharp and add additional logging to that method.
On my workstation (I'm not affected by the issue), I get through OnBrowserCreated with no exceptions. However, on my coworkers workstation I see the following line is failing:
...
channelFactory->Open();
auto browserProcess = channelFactory->CreateChannel();
auto clientChannel = ((IClientChannel^)browserProcess);
try
{
clientChannel->Open(); <-- FAILS
browser->ChannelFactory = channelFactory;
browser->BrowserProcess = browserProcess;
}
catch (Exception^)
{
}
}
With the error:
There was an error reading from the pipe: The pipe has been ended. (109, 0x6d)
Has anyone seen this issue before? I'm not sure how much this will help, but does anyone know if it's possible to enable WCF tracing with the CefSharp.BrowserSubProcess.exe. I have been trying this, but no luck so far.

I'm getting an unhandled GET request that I thought I explicitly handled

I'm currently following this tutorial on making a website with database persistence and just finished it (or so I thought) but whenever I try to load the main page I get an unhandled GET:
2022-04-30 12:28:17.720 [eventLoopGroupProxy-4-1] ERROR Application - Unhandled: GET - /articles
Yet I definitely handle it in my routing here:
route("articles") {
get {
call.respond(FreeMarkerContent("index.ftl", mapOf("articles" to dao.allArticles())))
}
Where dao is a data-access object with function allArticles() which returns a list of Article objects.
Heck, I even copy-pasted the entire Routing.kt from the tutorial to make sure it wasn't some small detail I or IntelliJ missed and I still get the exact same error.

Deserializing Media field fails in Piranha CMS

Modifying Piranha for 'headless' scenario: I separated the api into its own REST API, and the MVC into its own UI that calls the REST API. Mostly it works well, but now an obstacle. My REST API serializes the result from the Piranha api, and my MVC web deserializes it into a Piranha StandardPage type. This works for all fields except Media, which is always null. Using newtonsoft.Json.
The Media property is defined in Piranha.Extend.Fields.MediaFieldBase with internal set, which explains why I can't deserialize into it. So I added a [JsonProperty] attribute to the Media property. Once I did this, then the Media field was correctly deserialized by the MVC, and images appeared.
But then I found this broke something else: in the manager, when I try to save a page with a Hero image, the Save buttons spins, stops as though it succeeded, but the toast never appears saying success. I set Debug logging for Microsoft.AspNetCore.Mvc.Infrastructure, and see there's a model state error when this happens:
dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[2]
Executed controller factory for controller Piranha.JA.Manager.Controllers.PageApiController (Piranha.JA.Manager)
dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ModelStateInvalidFilter[1]
The request has model state errors, returning an error response.
dbug: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[3]
Request was short circuited at action filter 'Microsoft.AspNetCore.Mvc.Infrastructure.ModelStateInvalidFilter'.
I can debug into the PageApiController for most operations, but when Save executes none of the breakpoints are hit.
I also tried just removing the internal accessor from set (and removing [JsonProperty]) and got the same behavior: can deserialize Media ok but trying to save page with a Hero from manager gives model state error.
Would love to write up some documentation on how to go headless if we can solve this.
We've been debugging this one for a few days, can anyone help?
In the branch I pushed I actually changed the accessor to public, so you shouldn’t need the additional attribute. This is also merged to master and will be released in 8.3.
Regards
I posted this on the Piranha CMS github and one of its authors, Hakan Edling, answered in just a few hours:
"The root issue is that when a new item is selected in the manager in the media picker, the media model that is assigned contains a formatted string size "xxx kb". When ASP.NET tries to deserialize this into a long it fails.
So changing the following line in the .vue components for the media-based fields:
this.model.media = media;
to
this.model.media = {
id: media.id,
folderId: media.folderId,
type: media.type,
filename: media.filename,
contentType: media.contentType,
publicUrl: media.publicUrl,
};
Resolves the serialization error in the manager when the Media property is public.. I'll push this fix to a new branch so you can test it."
And soon after,
"Please test with the branch https://github.com/PiranhaCMS/piranha.core/tree/features/make-mediafield-media-public"
I still must add the [JsonProperty] attribute to the Media field in MediaFieldBase class, so my deserializer can access the internal set method. Hakan's fix makes it so this attribute doesn't break the manager.
Thank you for your quick response Hakan, you rock!

ExpertPdf - Could not get conversion result header. Data receive error. Could not receive data. Error code: 109

I am using ExpertPdf *HtmlToPdf* library. When I try to AddElement to PdfPage I get an exception:
"Could not get conversion result header. Data receive error. Could not receive data. Error code: 109". I have no idea why is that.
Code below:
PdfPage page = doc.Pages.AddNewPage();
HtmlToPdfElement htmlToPdfElement = new HtmlToPdfElement(0,0,0-1,"cos",null);
AddElementResult result = page.AddElement(htmlToPdfElement);
If you change application pool identity to user which has admin rights, it solves the problem.
I am not sure what the ExpertPdf is, however the error is similar to what is described in troubleshooting guide for EVO HTML to PDF Converter:
The conversion fails with 'Data receive error. Could not receive data. Exception of type 'System.OutOfMemoryException' was thrown', 'Memory allocation error. Try the 64-bit version', 'Data receive error. Could not receive data. Error code: 6', 'Data receive error. Could not receive data. Error code: 0', 'Data receive error. Could not receive data. Error code: 109' error messages or you see the 'Exception code: 0xc0000005' in Windows logs for evointernal.dat process
These error messages can indicate a memory allocation error in converter. In general you can avoid memory allocation issues by running the converter in a 64-bit environment. This is the recommended configuration for EVO HTML to PDF Converter. When you run the converter in ASP.NET you have to set the 'Enable 32-bit' flag of the IIS application pool on false to make sure the converter runs in a 64-bit process. It is also recommended to use the version of the converter optimized for 64-bit environments, which is provided as a separate download on our website. This version should also avoid the memory allocation issues that might occur during the navigation.
Looks like they use the same engine. Hope this helps.

Enabling REST on HMVC CodeIgniter setup

I have just finished setting up an HMVC CodeIgniter following the steps here.
I am now trying to create a module "api" which I wish to use Phil Sturgeon's REST library.
It states here that I need to extend the MX_Controller rather than the CI_Controller and I did.
My initial setup was like this
application
--modules
----api
------config
------controller
------libraries
I kept getting an error with loading Rest_Controller so I have tried moving the REST_Controller and Format libraries to application/libraries that seemed to fix the loading issue but now i am getting the error below whenever i try to access it via http://example.com/codeigniter/index.php/api/example/user/id/1/format/json
"An Error Was Encountered
Unable to load the requested class: security"
I am expecting for the output to be "{"id":1,"name":"Some Guy","email":"example1#example.com","fact":"Loves swimming"}"
What am I missing? Would it be possible to keep the REST_Controller and Format libraries under the api module? If so, how?
Source
Open Rest_Controller.php go to line 173 and change the following code
$this->load->library('security');
to
$this->load->helper('security');
EDIT:
To have the REST_Controller and Format libraries under the api module.
Move the REST_Controller to api/controllers/REST_Controller.php and Format to api/libraries/Format.php