Passbook web services to update a pass - node.js

I have created a web service to update our passbooks with the following entries in my routes file:
// Registering a Device to Receive Push Notifications for a Pass
app.post('/Passbook/v1/devices/:dli/registrations/:typeid/:serial', PBAdmin.registerDevice);
// Getting the Serial Numbers for Passes Associated with a Device
app.get('/Passbook/v1/devices/:dli/registrations/:typeid',PBAdmin.getSerialNumbers);
// Getting the Latest Version of a Pass
app.get('/Passbook/v1/passes/:typeid/:serial', PBAdmin.getUpdatedPass);
// Unregistering a Device
app.delete('/Passbook/v1/devices/:dli/registrations/:typeid/:serial', PBAdmin.unregisterDevice);
// Logging Errors
app.post('/Passbook/v1/log', PBAdmin.logErrors);
The problem is that after a passbook is downloaded by a user my web service end point receives a GET request instead of POST request for registering a device (from my log file)
GET /Passbook/v1/devices/xxxxxxxxxxxxxxe99ddc69a5a9/registrations/xxx.xxxx.xxxx.app.dev.passbook/1408646948910 401 18ms - 12b
In fact this happens for the log handler as well (which is supposed to be POST with error message). I am not sure why that is and how to fix it.

Related

How to catch errors raised in Azure Device SDK?

I am using the Azure Device SDK for .NET Core in order to connect my devices to Azure IoT Hub. From time to time the server rejects some messages (like twin updates or telemetry messages) from the devices and responds with status code 400. As a result there are exceptions thrown on client side but due to its asynchronous nature they are swallowed somewhere inside the Azure SDK and never thrown at my code.
How can I actually be notified about these errors so I can handle and display them?
I can also see from the Azure Device SDK code that it uses some kind of logging (EventSource) but this is never enabled in the code:
From Logging.Common.cs:
Log.IsEnabled() // always returns false
Can you point me to some way where I can 1) actually enable logging in the Azure Device SDK and 2) find the content that was actually logged?
Update: Details regarding exception that is swallowed somewhere
// Fired here after I send twin reported properties to server:
AmqpTransportHandler.VerifyResponseMessage:
if (status >= 400)
{
throw new InvalidOperationException("Service rejected the message with status: " + status);
}
// Then becomes caught and re-fired here:
AmqpTransportHandler.SendTwinPatchAsync:
throw AmqpClientHelper.ToIotHubClientContract(exception);
// Then it disappears somewhere in the "dance" of the async tasks
You can capture traces: https://github.com/Azure/azure-iot-sdk-csharp/tree/master/tools/CaptureLogs
Our sample demonstrates best practice regarding exception catching, for example: https://github.com/Azure/azure-iot-sdk-csharp/blob/master/iothub/device/samples/DeviceClientMqttSample/Program.cs

Camel AMQP autoAck failed to resolve an endpoint

I am trying to set autoAck to false while reading from azure service bus queue, which I am connecting using amqp. Below is the code.
from("amqp:queue:testqueue?autoAck=false&concurrentConsumers=1")
But I am getting an error msg:
Failed to create route route1: Route(route1)[[From[amqp:queue:testqueue?autoAck=false&concu... because of Failed to resolve endpoint: amqp://queue:testqueue?autoAck=false&concurrentConsumers=1 due to: Failed to resolve endpoint: amqp://queue:testqueue?autoAck=false&concurrentConsumers=1 due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{autoAck=false}]
I am trying to process the messages from the service bus queue but don't want them to be removed till the time processing is not complete.
I finally found the answer, in order to remove the messages from the queue only when a consumer has accepted the message and acknowledged that it was successfully processed, you need to add "acknowledgementModeName" to the route
from("amqp:queue:testqueue?acknowledgementModeName=CLIENT_ACKNOWLEDGE&concurrentConsumers=1")
For more clarification visit this page http://camel.apache.org/jms.html

Azure backend return 500 in PATCH operation

I am desperately trying to debug an error 500 only when I try to update an object from my xamarin.Forms offline DB to Azure. I am using Azure Mobile Client.
I set all the logging to ON in azure, then I downloaded the log. I can see the generic error, but nothing useful.
<failedRequest url="https://MASKED:80/tables/Appel/9A3342A2-0598-4126-B0F6-2999B524B4AE"
siteId="Masked"
appPoolId="Masked"
processId="6096"
verb="PATCH"
remoteUserName=""
userName=""
tokenUserName="IIS APPPOOL\Masked"
authenticationType="anonymous"
activityId="{80000063-0000-EA00-B63F-84710C7967BB}"
failureReason="STATUS_CODE"
statusCode="500"
triggerStatusCode="500"
timeTaken="625"
xmlns:freb="http://schemas.microsoft.com/win/2006/06/iis/freb"
>
The table that failed is the only one I extend with some virtual runtime calculated field of navigation field. But I add the [JsonIgnore] to stop AzureService to create field in the local DB (that work) or send it on the wire to the server. But I always got the 500 error, not exception when debugging the c# Azure backend too.
How I can find the stack trace or the "deep" reason for this 500 error in my backend?
For C# Mobile App backend, you could add the following code in the ConfigureMobileApp method of your Startup.MobileApp.cs file for including error details and return to your client side.
config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
You could just capture the exception in your mobile application or leverage fiddler to capture the network traces when invoking the PATCH operation to retrieve the detailed error message.
Moreover, you are viewing the Failed Request Traces log, you need to check the Application logs. Details you could follow Enable diagnostics logging for web apps in Azure App Service.

Xamarin.Android & Azure Push Notifications Internal Server Error

I'm following the guide at https://learn.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-xamarin-android-get-started-push (as well as the original Xamarin one that this appears to have cribbed from), but I'm running into a problem registering my client.
I am successfully logging a user in prior to setting up the push notification service.
Both GcmClient.CheckDevice(...) and GcmClient.CheckManifest(...) succeed, and my PushHandlerService is being called.
Push.RegisterAsync(...) in my PushHandlerService is throwing a MobileServiceInvalidOperationException because it received an HTTP 500 Internal Server Error from the service.
Looking at FREB logs, it appears that the "error" is actually supposed to be a success, and interestingly is somehow related to the EasyAuthModule:
NOTIFY_MODULE_COMPLETION ModuleName="EasyAuthModule_64bit", Notification="AUTHENTICATE_REQUEST", fIsPostNotificationEvent="true", CompletionBytes="297", ErrorCode="The operation completed successfully.
(0x0)" 05:51:01.092
Module_set_response_error_status
Warning ModuleName="EasyAuthModule_64bit", Notification="AUTHENTICATE_REQUEST", HttpStatus="500", HttpReason="Internal Server Error", HttpSubStatus="79", ErrorCode="Unspecified error
(0x80004005)", ConfigExceptionInfo="" 05:51:01.092
NOTIFY_MODULE_COMPLETION ModuleName="EasyAuthModule_64bit", Notification="AUTHENTICATE_REQUEST", fIsPostNotificationEvent="true", CompletionBytes="0", ErrorCode="The operation completed successfully.
(0x0)" 05:51:01.092
I take it the error is happening when you call client.GetPush().RegisterAsync()? This is currently an issue and we are deploying a fix on the Azure side to fix this. In the interim, you can see the fix for this here: https://adrianhall.github.io/develop-mobile-apps-with-csharp-and-azure/chapter5/android/

SessionCloner.getSessionCloner().getSession() notesagent You are not authorized to perform that operation

Summary:
Domino server 8.5.3 Windows server 2008 FP2.
When calling
NotesAgent.runOnServer(noteid)
from a web browser in a Thread where agent is set to "run as web user", I am getting error "HTTP JVM: You are not authorized to perform that operation".
Detail:
All web requests come through 2 channels into our application, via a notes agent or via an xpage (that acts like an XAgent). We have a back end process that can take up to 20 seconds to complete, it is a call to a remote web service and we have no control over it. Due to requirements we can not queue these documents for a scheduled agent, they need to go immediately...or as immediately as the service will allow! The 2 main problems are: 1..the user has to wait up to 20 seconds, 2..the http thread is not freed up. During a busy time, we have seen the http thread pool saturate. What I have done in my test environment is send the request into the XAgent, this calls our backing bean which starts a separate thread, returns message to user. It's working great, http thread frees up immediately and a timely response for user and submission to web service proceeds "asynchronously".
The logic calling the web service is in LotusScript, converting to java would be a massive job as there are an enormous amount of interconnected processes in LotusScript. In the java thread the username is the server name, effectiveUserName is the authenticated http user, the thread calls a
NotesAgent.runOnServer(noteid)
, which works, except the agent runs with credentials of the user that signed the agent. If we set the agent to "Run as web user", I get the error above. As a test, I moved the code that triggers the NotesAgent.run() into the main "calling" function, which gets it's session via:
JSFUtil.getVariableValue("session")
and this works as expected (user=server, http user=effective user). The thread session is got like this:
this.module = NotesContext.getCurrent().getModule();
this.sessionCloner = SessionCloner.getSessionCloner();
NotesContext context = new NotesContext( this.module );
NotesContext.initThread( context );
session = this.sessionCloner.getSession();
...and as above, the effective User Name is the authenticated http user, the user name is the server name.
If I browse directly to the agent, e.g. .../myapp.nsf/myagent?openagent, the agent will run as the effective http user. I then put my test http user into the highest security group I have on my test server, same error. I then logged in as a server admin user (that has security settings for everything) and got same error.
On my test serrver I have: Domino\jvm\lib\security\java.policy when running the Job from the NSF:
grant {
permission java.security.AllPermission;
};
Since I can trigger the agent via JSFUtil.getVariableValue("session") is there some security difference when getting a session via SessionCloner.getSessionCloner().getSession() ?
Thanks in advance.
Agents and XPages shall not interbreed :-). For the thread I would remove the need to get the web user. Pass a java object to the thread that does not contain any Notes objects. Then go old school and use sInitThread stermThread to get a shiny new session and run the agent from there.

Resources