How to get the actual failing reason for customPairing.PairAsync? - c#

Working in c# Wifi Direct Windows to Android Device pairing. Getting below result status "Failed".
result = await customPairing.PairAsync(DevicePairingKinds.ConfirmOnly);
How can I get the detail information and reason for failing?

How to get the actual failing reason for customPairing.PairAsync?
I'm afraid you can't get the detail info from PairAsync method, currently UWP has not provided the detail reason when paired failed. You could only get limited state explain here. It means An unknown failure occurred If the state is Failed. If you do want this feature please feel free post your requirement with windows feed back hub app.
By the way you may check if system Event Viewer contains such failed reason.

Related

Getting 'couldn't send retry' error in web chat for questions which are not present in knowledge base

I created a bot with Azure in C#. This bot is working fine for question which are present in my knowledge base. But when I try different question, it gives error couldn't send retry below that question and reply to that question as Sorry, my bot code is having an issue.
It should reply No match found instead of Sorry, my bot code is having an issue.
One more issue is this bot sometimes gives random answer form KB for some questions which are not present in Kb instead of No answer found in KB.
In web chat channel, it shows following issue - There was an error sending this message to your bot: HTTP status code InternalServerError.
Any help will be appreciated.
First of all, regarding that tutorial:
This article uses Bot Framework v3 SDK. Please see this Bot Framework article, if you are interested in Bot Framework v4 SDK version of this information.
It's old and uses V3 of the Bot Framework SDK. I highly, highly recommend building any new bots in V4. Use the Add natural language understanding tutorial instead.
InternalServerError indicates that there's a problem with your bot code, somewhere.
Here's a few things you can try that are likely causing the issue:
Write code that deals with No Answer
The official QnAMaker Sample does that here:
// Query QnAMaker for Answer
var response = await qnaMaker.GetAnswersAsync(turnContext);
// If we have an answer, send it to the user
if (response != null && response.Length > 0)
{
await turnContext.SendActivityAsync(MessageFactory.Text(response[0].Answer), cancellationToken);
}
// If we don't have an answer, tell that to the user
else
{
await turnContext.SendActivityAsync(MessageFactory.Text("No QnA Maker answers were found."), cancellationToken);
}
Ensure your QnAMaker Service has a DefaultAnswer
This is likely only an issue if you set up your bot to get a default non-answer from your QnAMaker Service.
In Azure Portal > Resource Group > QnA App Service > Configuration (note: this is NOT your bot's app service; this one is specific to QnAMaker), ensure DefaultAnswer is set:
Debug
Assuming that your bot is actually breaking only when and because no QnA Answers were found, those two things should be the only thing you need to troubleshoot. Otherwise, here's how to debug a bot:
Visual Studio/C#:
In Visual Studio, run your bot by pressing F5 or clicking:
Open your bot in Emulator
In Visual Studio, go to Debug > Windows > Exception Settings:
In the Exception Settings window, full-check "Common Language Runtime Exceptions"
In Emulator, do the thing that makes your bot break. The bot should automatically stop when there's an error. Here, I've forced one:
As you can see, it says System.IndexOutOfRangeException: 'Index was outside the bounds of the array.' This means that my array, response doesn't have a 0th element because no answers were returned.
Other issues will show other errors. You can usually pinpoint issues fairly easily by reading the error details and doing a web search for the error code if you need additional details.
VS Code
In VS Code, run your bot by pressing F5 and selecting 'Node.js' (for Node/TypeScript bots) or .NET Core (for C# bots):
Open your bot in Emulator
In VS Code, open the Debug menu:
Under "BREAKPOINTS", check "All Exceptions" (Note: It's important to run your bot before checking this box because there are normal exceptions that occur when the bot starts up):
In Emulator, do the thing that makes your bot break. The bot should automatically stop when there's an error. Here, I've forced one:
As you can see, it says Exception has occurred: TypeError TypeError: Cannot read property 'answer' of undefined This means that qnaResults[0] is undefined, or doesn't exist, which indicates that no answers were returned.
Other issues will show other errors. You can usually pinpoint issues fairly easily by reading the error details and doing a web search for the error code if you need additional details.

Inaccessible logs: Security. The source was not found, but some or all event logs could not be searched

I am assuming it has something to do with my app pool/IIS but why is this error only being thrown while in Production?
To Start- I have read every related question about this topic on SO.
I cannot reproduce this error in my Dev and/or Test environments. I have sent hundreds of POST requests using postman(DEV), I have also used my iOS application pointing to my Test Environment and sent thousands of requests and I am still in the same boat.
About my Project: I am using WebAPI and my application is running on iOS10 written in swift. I only receive this error occasionally and cannot reproduce it on command. I am wondering if anyone else has run into this issue and if so, what were the steps you took to take care of this problem?
Error #1
The source was not found, but some or all event logs could not be searched.
To create the source, you need permission to read all event logs to make
sure that the new source name is unique. Inaccessible logs: Security.
Note: This error is not causing me to lose any data when I receive it, all records are still being committed to my database. So it is not a huge issue since I only get the error 1 out of about 100 times a new record is submitted. But curiosity is killing me and wanted to see if anyone had any suggestions.

ProcessReceivedMessage Error in MqttDotNet

I am building a .NET IoT project that requires MQTT for communication. For the broker I use GnatMQ and for clients I use MqttDotNet (for mobile compatibility). The client library builds, connects, and sends messages fine but I get an error whenever the client’s PublishArrivedDelegate is triggered (i.e. message received event).
The error occurs on retained messages as well as standard received messages. The MqttDotNet error log is here.
Console output:
It seems the error is captured in the QoSManager.cs on line 91:
else if (mess.QualityOfService == QoS.OnceAndOnceOnly)
{
_responses.Add(mess.MessageID, new MqttPubrelMessage(mess.MessageID));
}
NOTE: I am using the raw libraries (as they are) without added code.
Has anyone tried these libraries and can maybe confirm that it worked for them without issues? Until then, I guess it's debugging till the extreme.
Update 1: The error only persists on subscribe with QoS level 2.
Update 2: The error can be prevented by adding a handle to prevent duplicates from being added to the hashtable, as pointed out by #hardillb . But this does not SOLVE the actual issue here.
The issue still persists on publish and subscribe with QOS 2. The problem is that the onClientPublishedArrived is being triggered exactly 3 times whenever a message gets received and exactly 2 times when a message get received as retained. NOTE that when I test this with HiveMQ the issue is gone. The problem only persists when using the GnatMQ broker.
Looks like you are trying to add duplicate keys to a Hashtable, this will be being caused by mess.MessageID returning the same value for multiple messages.
The C# implementation looks like it throws an exception rather replacing the original value with the new value.
If you just need a unique key for the Hashtable you could use something like the timestamp

Getting the Source channel of a call from Asterisk

I am developing a CTI Client for Asterisk, and handling one extension at a time.
When a call is coming, I can get all the details but the channel of source phone. I have seen the Dial event gives the Source Channel. But As I am not handling the Source Phone (Using Proxy), I am not getting events from Source Phone. How can I get it. Please Help!..
Thanks
You can use in your dialplan
exten => s,n,UserEvent(ParentChannel,${BRIDGEDPEER})
For more info see
http://www.voip-info.org/wiki/view/Asterisk+Detailed+Variable+List
http://www.voip-info.org/wiki/view/Asterisk+cmd+UserEvent
Also you can do DumpChan to see all variable on channel any time in your asterisk console
http://www.voip-info.org/wiki/view/Asterisk+cmd+DumpChan

Mathematica .Net/Link in an Asp.Net application

I am using the Mathematica .Net/Link platform to create a web service to format and calculate math problems. However I am unable to get it working.
I create it using this code:
_Log.IpDebug("Starting the Kernel Link");
if (string.IsNullOrEmpty(_MathLinkArguments))
_InternelKernel = MathLinkFactory.CreateKernelLink();
else
_InternelKernel = MathLinkFactory.CreateKernelLink(_MathLinkArguments);
_Log.IpDebug("Kernel Link Started");
_InternelKernel.WaitAndDiscardAnswer();
The value of _MathLinkArguments is -linkmode launch -linkname \"C:\\Program Files\\Wolfram Research\\Mathematica\\7.0\\Math.exe\".
This piece of code is called from the Application_Start method of the global.asax.cs file.
When it gets to the WaitAndDiscardAnswer() call it gives the server error:
Error code: 11. Connected MathLink program has closed the link, but there might still be data underway.
Note: The SampleCode given with the .NET/Link package (both a console app and a WinForms app) works.
Edit:
I copied the console app sample code given with Mathematica into an asp.net page and it gave me the same error the first load and then on subsequent loads it gave me:
Error code: 1. MathLink connection was lost.
Edit2:
I forgot to mention that when I have procmon and task manager open while running my app, I can tell that Math.exe starts but it immediately exits, which makes those error code make complete sense...but doesn't explain why that happened.
To allow the .Net/Link to work in Asp.net (at least in IIS 7.5) you need to enable the property loadUserProfile on the app pool for the web site.
I am not entirely sure why this is the case, but from what I found while trying to debug this, there are some things that are gotten from the user's profile. I know for a fact that the default location of the kernel is, which explains why I couldn't use it with no arguments, and so I can only assume that other things are needed as well and without the profile it couldn't determine that.
But whatever the reason is this is required, it is, or at least it is a fix if you are getting similar problems like this in your own application.
I got the same error in a .Net WinForm application.
mathKernel = new MathKernel();
mathKernel.Compute("<< XYZ`XYZGraphs`");
The error occurred on loading the package straight after instantiating the MathKernel.
To resolve it you can wait a couple of seconds and then instantiating the MathKernel works fine. During this state where there might still be data underway the following conditions are both false:
if (!MathKernel.IsConnected)
{
MathKernel.Connect();
}
if (MathKernel.IsComputing)
{
MathKernel.Abort();
}
Edit:
I've recieved the error again and this time was able to determine the problem.
Using a command line open the MathKernel.exe and view the error message:

Categories