In Azure i have created a sample notification hub and tried to send test Toast notification for windows. And i ended up with below exception in Azure.
Failed to send test message. Error: {"readyState":4,"responseText":"{\"error\":{\"message\":\"Bad Request\",\"code\":\"BadRequest\"}}","responseJSON":{"error":{"message":"Bad Request","code":"BadRequest"}},"status":400,"statusText":"Bad Request"}.
[Find the screenshot for reference]
https://i.stack.imgur.com/6tbFm.png
You need to configure the Windows(WNS) under Notification Settings first. You can follow this document(https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-windows-store-dotnet-get-started-wns-push-notification#configure-wns-settings-for-the-hub)
I have tested it on my side, after following all the steps in the document, it works fine.
Related
It seems that we programmed everything correctly because when we use a test app that we made everything works fine. But now that were trying to create the real app it doesn't work. When we try to send a push message from Notification Hubs we get the message "message was successfully sent but there were no matching targets". We tripple checked all the necessary fields and everything is the same. Somehow the message is not being delivered and we can't find the reason why.
I'm trying to test botframework server on my localhost.
I followed the steps in https://learn.microsoft.com/en-us/azure/bot-service/bot-service-troubleshoot-authentication-problems?view=azure-bot-service-4.0#step-3-enable-security-and-test-on-localhost- .
First I changed app config with the MicrosoftAppId and MicrosoftAppPassword passed the test of https://learn.microsoft.com/en-us/azure/bot-service/bot-service-troubleshoot-authentication-problems?view=azure-bot-service-4.0#step-2 .
Then I started my bot on localhost and the web page shows it was running on http://localhost:3979/ .
But when I tried to test it on the Bot Framework Emulator, it returned 400 directline.postActivity with the message of "Refresh access token failed with status code: 401".
The screenshot is on https://i.loli.net/2019/06/06/5cf88ea120b9973175.png .
My botframework version is 3.13.1.
My Bot Framework Emulator version is 4.3.3.
What should I do to solve this problem?
Thanks for any help.
{
"error": {
"code": "ServiceError",
"message": "Refresh access token failed with status code: 401"
}
}
[11:42:22]POST 201 directline.start Conversation
[11:42:22]Emulator listening on http://localhost:49840
[11:42:22]ngrok listening on https://082d32c4.ngrok.io
[11:42:22]ngrok traffic inspector:http://127.0.0.1:4040
[11:42:22]Will bypass ngrok for local addresses
[11:42:25]->message hi
[11:42:26]POST 400 directline.postActivity
"Refresh access token failed with status code: 401" errors are almost always an issue with appId/appPass.
Please verify:
You have the correct appId/appPass from the App Registration Portal
Note: If you didn't save your password, just click "New client secret" to generate a new one.
Verify you set the correct appId/appPass in web.config
Verify that you entered the correct app/Id/appPass in Emulator:
You should also upgrade Emulator to the latest release. There was a bug in Emulator long before 4.3.3 that caused this error, but I guess there could be something similar with V3 bots, since we rarely use them.
If this is a new bot, you should really be using V4. V3 will be deprecated July 1, 2019. Existing bots will work, but users will no longer be able to create them.
I've a web job that is trying to send an email when it reads something from the Azure poision q.
public static void ProcessPoisonNotification(
[QueueTrigger("parkingticketnotification-poison")] ParkingTicketNotificationBO notificationBo,
TextWriter log)
{
var message = "xxx xxx xxx xxx xxx => POISON message: " + notificationBo.Dump();
Console.WriteLine(message);
log?.WriteLine(message);
PoisonEmailNotifier.SendFailureMessage(notificationBo);
}
The Email notifier is using code from the main web applicaiton, which can send emails. but the Web job throws the following exception. Is it because the web application is blocking port 25?
The Email notifier is using code from the main web applicaiton, which can send emails. but the Web job throws the following exception.
Base on my experience, as the Web application and WebJob are in the same environment, if it is worked in the Web application, it should be also worked in the Azure WebJob.
If WebJob is worked locally, please have a try to remote debug the WebJob. More details about how to remote debug the webjob, please refer to the tutorials.
Note: Click the Settings tab, and change Configuration to Debug, before it is published.
Besides,we also can use Azure SendGrid to send email easily.
That looks like Windows Socket Error Code 10013. You can find out more about it here.
Microsoft has two suggestions - you likely either have insufficient permissions or another service is bound to the target port. If you know that traffic on port 25 is not open on your host, it seems likely that this is the cause. However, you may instead have some other service listening to that port.
I'm trying to test talking to apple's push notification sandbox server.
I made a certificate following this link
(enabled push notification, requested certificate authority, uploaded, generated cert, export p12)
I made a sample C# console application that looks like the following
PushBroker push = new PushBroker();
var appleCert = File.ReadAllBytes(#"devapns.p12");
push.OnNotificationSent += NotificationSent;
push.OnChannelException += ChannelException;
push.OnServiceException += ServiceException;
push.OnNotificationFailed += NotificationFailed;
push.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
push.OnChannelCreated += ChannelCreated;
push.OnChannelDestroyed += ChannelDestroyed;
push.RegisterAppleService(new ApplePushChannelSettings(false,appleCert,"password"));
push.QueueNotification(new AppleNotification()
.ForDeviceToken(token)
.WithPasskitUpdate());
push.StopAllServices(waitForQueuesToFinish: true);
When I run I get
The maximum number of Send attempts was reached
The version of PushSharp I'm currently using is 2.2.1.0
Is there something else I need to do? Do I need to enable SSL somewhere? Is my certificate not properly installed on my local machine. I'm not sure where I am going wrong.
NOTE: the p12 file is about 3KB
I installed the development certificate on my local computer just for testing when running this console application
UPDATE:
I managed to get notifications successfully being sent to apns. However, the only problem is that passes do not update on the user device. According to this link, my webservice is to get a list of valid serial numbers once invoked by the device after receiving a passbook update notification from APNS. However, this never happens.
It seems as if I can successfully send my notification to the Apple Notification Service, but from there the apns cannot send it to the device. Any thoughts?
Right now I am signing the pass and sending a notification to APNS using the same pass type ID certificate.
So I was finally able to update a pass in passbook using APNS. It was an arduous process and there were many different things I didn't take into account. Here are a couple things to keep in mind.
Be sure you use the same .p12 file when signing the pass and using pushsharp. (I had originally used a different .p12 associated with regular push notifications). So the link I originally posted in the question is a tad bit misleading, you would follow those steps for regular push notifications. But for passbook notifications, you need use the .p12 file associated with your Pass Type ID
In PushSharp, be sure to disable the production/sandbox certificate check. There is no sandbox environment for passbook, so everything should point to production. In this line, add an extra true parameter to disable the check
push.RegisterAppleService(new ApplePushChannelSettings(false,appleCert,"password", true));
Be sure you aren't using a test device when testing. Also you cannot use the simulator
The push token you receive is different than the DeviceIDToken you would receive when registering for regular push notifications. The push token is passbook exclusive
Ensure the proper certificates are installed on your server. For example I had to install the pass type ID certificate
Do a telnet feedback.push.apple.com 2196 to ensure you can hit the apns server
We are trying to use the NotificationHubClient in Microsoft.ServiceBus.Notifications. We are having a strange problem which the code below shows where we register the Device like so:
NotificationHubClient client = GetHubclient();
var task = client.CreateMpnsNativeRegistrationAsync(deviceToken, tags);
Task.WaitAll(task);
This registers the device fine and if we send a test toast message from the azure portal debug page it comes through to the windows phone without issue. However if we call the following:
var sentTask = client.SendMpnsNativeNotificationAsync(GetPayload());
Task.WaitAll(sentTask);
private static string GetPayload()
{
return "<wp:Notification xmlns:wp=\"WPNotification\"><wp:Toast><wp:Text1>Great News</wp:Text1><wp:Text2>Great News</wp:Text2></wp:Toast></wp:Notification>";
}
No toast notification arrives on the phone and if we then go and try to send a test toast notification again from the debug page of the azure portal it no longer works and the following error is displayed:
The Push Notification System handle for the registration is invalid
None of this is making sense, we have enabled testSend and there are no errors coming back from the client in the code, in fact it says everything was successful the first time even though this appears to break the PNS handle.
Has anyone come across this before?
It turns out that if the Xml declarations are missing:
<?xml version="1.0" encoding="utf-8"?>
Then you can no longer send push notifications to any phones you tried to send a push notification to as it is invalidated. This seems pretty awful, sure don't send the notification if the payload is invalid but why invalidate the PNS.