Currently, I'm developing a Windows Phone 8.0 application that displays some 100 GPS locations on a map. The GPS data is obtained by calling a RESTful webservice as follows:
public async Task<string> GetWebContent(string uri)
{
string result = null;
using (var client = new HttpClient())
{
result = await client.GetStringAsync(new Uri(uri));
}
return result;
}
Here, the HttpClient is taken from the Nuget Package "Microsoft HTTP Client Libraries".
The first time the code is called, data is obtained and the GPS locations are nicely plotted on a map. However, since the GPS devices move constantly, I have to refresh the data every 30 seconds. This is where I hit the wall; the data contained in the variable "result" never changes. Even after several minutes the data is the same. The raw data contain a datetime property, which clearly tells me that the data is old and not just the GPS devices standing still. If I paste the uri into a webbrowser, and hit the refresh butten every 15 sec, the data does changed hence the webservice is working properly.
Since the HttpClient is contained in a using-statement, it is disposed off every time and some hidden caching mechanism seems impossible. So, does anyone have an idea?
cheers
Update
I tried using Fiddler, but had to follow a lengthy instruction to make it connect with the emulator. Once done, nothing worked anymore :-s Reverting all the certificates that Fiddler installed and copied the code to a regular WPF application and there it works als a charm.I'm no closer to an understanding of what's going on, but the problem seems to be related to the fact that it's a windows phone project.
It maybe caching the result from the first call. You may need to set the IfModifiedSince property in the request header before each subsequent call to ensure that its getting the latest value.
Example code from: https://stackoverflow.com/a/17884734/61226
client.DefaultRequestHeaders.IfModifiedSince = DateTime.UtcNow;
See similar issues here:
No cache with HttpClient in Windows Phone 8
Caching issue with WebClient/HttpClient
Related
We have a Teams bot that posts messages in MS Teams. The first activity of a new conversation is always an adaptive card and once in a while, we update that with a new card. This worked OK until I made a new Team with this bot.
The update we are trying with UpdateActivityAsync, return NotFound.
After some troubleshooting, I noticed the following:
The new team has a different name: 19:...#thread.tacv2 as opposed to 19:...#thread.skype.
When I use an older team, it works as expected.
When I update the activity with text only (so no adaptive card as attachment) it will always update as expected.
After an update with a text, we are able to update with an adaptive card ONCE. After one update with an adaptive card, any subsequent updates with adaptive cards will return NotFound.
So, as a workaround, I now first update with text and immediately after that I send the update with the card. Which is a bad UI thing (flickering) but it works for now.
We use the old bot framework version 3, which I know is not maintained anymore, but as far as I can find, it should still work (no plans to discontinue operation). Also given the above points (specifically point 4) I would expect it uses the same calls under the hood.
So, this works for older teams, but not for a team with #thread.tacv2
await connector.Conversations.UpdateActivityAsync(
teamsConversationId,
activityId,
(Activity)messageWithCard);
And for teams with #thread.tacv2 we now have to use this
var messageWithText = Activity.CreateMessageActivity();
messageWithText.ChannelId = teamsConversationId;
messageWithText.Id = activityId;
messageWithText.Type = ActivityTypes.Message;
messageWithText.Text = "Updated";
await connector.Conversations.UpdateActivityAsync(
teamsConversationId,
activityId,
(Activity)messageWithText);
await connector.Conversations.UpdateActivityAsync(
teamsConversationId,
activityId,
(Activity)messageWithCard);
The exception does not provide too many details:
Operation returned an invalid status code 'NotFound'
Conversation not found.
Does anyone know how to avoid this change between teams and allow updates of activity with cards?
Also (and this is much less important, but I think it's useful to add) I noticed that sometimes (I've seen it twice now) Teams seems unable to render the adaptive card and displays URIObject XML instead, containing error: cards.unsupported. However, if I exit the client and restart it, it renders fine... I have never seen this so far in the old channels.
Teams client version 1.3.00.362 (64-bit) (no dev mode).
Normal Azure tenant (no preview/trial)
EDIT 11/05/2020 It seems that this also happens on teams with the 'old' name (#thread.skype). So the '#thread.tacv2' seems unrelated.
We weren't able to find logs at the exact timestamps that you provided, but did find logs for the conversation ids on those dates and see 404s with the same minute and seconds in UTC. We assume the time stamps that were provided are represented in a different timezone.
From the logs we are seeing the following pattern:
Bot sends PUT activity with card - 404 returned
Bot sends PUT activity with text - 200 returned
Bot sends PUT activity with card - 200 returned
This looks like the same pattern that you shared in your original post.
There is a scenario that's causing 404s to be returned on PUTS whenever the bot tries to update an existing card message with the exact same card after new messages have been sent to a reply chain
These are the repo steps:
Bot send card to reply chain (can be root message or reply message)
Any user sends a message to the chain
Bot attempts to update message with the exact same card
Is it possible that your bot is encountering this? Is there a way to check whether the card your bot is sending in the first PUT request is the same card that is already in the original message
I have my Asp.Net WebApi hosted on Godaddy windows shared hosting.
When I access my api from different devices/machines, It takes around 30 sec for first request; after that, it works fine.
What is the issue? Can I make my web api run all the time? If so, how?
I have used Entity framework code first approach . Every time I face this issue when I call this api from my website which is:
Rs Travels - Go to holidays, click on domestic, see the slowness of web api.
Is there any way I can improve the performance of the web api?
If the API is not used often, it will take time on the first request to make things ready, it's the same if you restart IIS generally, things need to warm up.
Internally, we have a custom healthcheck system that calls specific URLs to monitor them, but as a consequence, it also keeps the service alive.
You could also do this fairly simply by creating a windows scheduler task locally, or on any server that simply calls the API periodically. It might be best to implement a specific Monitor method that performs any other keepalives that might be relevant.
Try this as an example Open Website from windows scheduler
It would be kinda difficult to change it since you do not own the web server (and thus its pool). You could try to call the api before you will actually need it (imagine a splash screen). Then it will be ready when you will actually need it. Of course, this will not work if form the initial page you are calling the API...
This worked for me !
https://stackoverflow.com/a/9474978/6426192
static Thread keepAliveThread = new Thread(KeepAlive);
protected void Application_Start()
{
keepAliveThread.Start();
}
protected void Application_End()
{
keepAliveThread.Abort();
}
static void KeepAlive()
{
while (true)
{
WebRequest req = WebRequest.Create("http://www.mywebsite.com/DummyPage.aspx");
req.GetResponse();
try
{
Thread.Sleep(60000);
}
catch (ThreadAbortException)
{
break;
}
}
}
I've installed a MSPL script to redirect INVITE audio messages to the UCMA sip address
I'm currently writing a UCMA app for Skype for Business to:
receive incoming calls
accept the call
create a conference call
add a trusted participant to the conference
create a recording instance on the trusted participant audio flow to record the conversation
The last thing I need to do is add the To caller URI to the conference call.
I've tried to invite the new participant into the conference using the code examples from this article, but I get an exception saying there are no AvailableMediaTypes in the conversation.
public static async void InviteToConference(string destinationUri)
{
//Create a new conversation for the application endpoint.
_toConversation = new Conversation(_server.ApplicationEndPoint);
var conferenceInviteSettings = new ConferenceInvitationSettings();
conferenceInviteSettings.ConferenceUri = _conferenceUri;
ConferenceInvitation invitation = new ConferenceInvitation(_toConversation, conferenceInviteSettings);
try
{
await invitation.DeliverAsync(destinationUri);
}
catch (InvalidOperationException)
{
// Conversation was terminated while trying to add participant.
}
}
Can someone please show me what I need to do to add / invite a participant into a conference call?
It would be even better if someone could show me how to record a Skype for Business call without the need to create a conference, as a conference can't be forwarded.
Your code looks like the old way (UCMA 3) of doing it. Have you tried this.
e.g.
McuDialOutOptions mcuDialOutOptions = new McuDialOutOptions();
mcuDialOutOptions.ParticipantUri = "sip:alice#contoso.com";
mcuDialOutOptions.ParticipantDisplayName = "Alice";
mcuDialOutOptions.PreferredLanguage = CultureInfo.GetCultureInfo("en-us");
conversation.ConferenceSession.AudioVideoMcuSession.BeginDialOut("tel:+14255551234", mcuDialOutOptions, dialOutCallback, state);
Using this sort of method to record very specific and low traffic should be fine but when you start to scale it up then you are going to hit all sorts of problems.
As for how to do it without a conference:
There is no way to do it fully with the supplied Microsoft API's.
What you have to do is implement, buy or use open source libraries for the following pieces:
sniff network packets
decode RTP/SRTP streams
decode the audio and/or video codecs used between the callers
encode streams into your desired format and save somewhere
To get access to the SRTP streams encryption setup and to figure out what the dynamic payload types for the audio/video codecs used, you also need to know the SDP offered and answered between the calling parties. You also need access to the SIP traffic to determine the calling parties to know who called who. This can be a lot more trouble than what it seems...
To get the SIP/SDP information there are two options that I know of:
Skype/Lync Server SDK (MSPL / Server Application) to see most of the SIP traffic. This is what I've used to implement a recording solution.
Skype/Lync SDN SDK - I haven't used this API but it seems to give access to the SDP so it should work.
If you get all these peices into place then the next problem is you can only "record" (basically "sniff") what you can see. If you can't see the RTP/SRTP traffic you can't record the calls.
So you need to have the sniffer part of the recording software on areas of the network that see the traffic you want to record. For example if you wish to record all PSTN calls, you can have a network spanning port off the Skype mediation servers.
If you wish to record ALL calls, then that gets a lot harder. You most likely need to either:
Force all media trafic to go through a known place (like the Edge server) and put sniffers on the that network.
Have lots of sniffers in strategic areas of the network to capture most RTP/SRTP traffic.
The problems with the above solutions are:
Forcing all the traffic through one point can cause performance issues (like you will see with your conference setup) once load starts to increase. Also forcing external (edge server users) and/or federated calls through this one point can cause a problems. Think edger server user calls to edge server users where the media traffic may not even go into your network at all but live only on the internet. Forcing the trafficing into your network can cause performance issues.
When not forcing all the traffic through one point, you may never be see all skype user to skype user calls depending on your network setup. Calls between Edge server skype users are even more of a problem as the media traffic may not even enter your network at all.
On top of all that there are the general problems of storage management (recording after a while will start taking up a large amount of disk space) and call recording management (e.g. searching for a specific call) and user security around these recordings to deal with. I'm sure I'm missing a lot but those are the basics.
If recording in not going to be a core component, you could just buy a 3rd party call recording solution that supports Lync/Skype.
Similar to this question which invokes the Windows 10 store to allow a user to write a review or rate an app, I'd also like to be able to invoke the Windows 10 Feedback app and allow users to provide feedback there.
I cannot seem to find much information on:
How this works in general. Can any old app use this service? (I
notice it just kind of shows whatever apps I have running)
How to invoke the Windows Feedback app with my package id
In short - not that I can see.
Other apps are invoked via protocol activation. I haven't seen this documented for the feedback app though so I have to err on the side of 'we haven't made this available yet' (I'm still checking though)
Here's an overall guide to the process http://blog.jerrynixon.com/2012/10/walkthrough-using-windows-8-custom.html?m=1
When I look in the registry under HKEY_CLASSES_ROOT\Extensions\ContractId\Windows.Protocol I see (shortened a tad)
[HKEY_CLASSES_ROOT\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.WindowsFeedback...\ActivatableClassId\App.AppX7eaybq6p4x7d4jgd6w6jk7r5dg6yhmbf.mca\CustomProperties]
"Name"="windows-feedback"
So - give that a try via launching windows-feedback
If I do Windows Key-R (run): windows-feedback://
it works fine so this should work:
var uri = new Uri(#"windows-feedback://");
var success = await Windows.System.Launcher.LaunchUriAsync(uri);
if (success)
{
// URI launched
}
else
{
// URI launch failed
}
Update
I've done some searching and it seems the magic parameter there is
windows-feedback:?contextid=522
That launches the NFL feedback for example. This is a predetermined number - I'm not sure how one gets on this list though.
Is it correct that everytime i call PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync() to get my push channel a new Uri for my App is generated? I'mean the expiration time of the channel is about 1 month, but why is there generated a new one if it is not expired? I'need to send the URI everytime to my push server who needs to update the database. For 100 Users this might be okay, but we got > 2mio users.
It shouldn't change that often but may change before the expiry time if requested again. How are you making multiple calls?
If I put this in an app I get the same thing both times.
var uri = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
System.Diagnostics.Debug.WriteLine(uri.Uri);
var uri2 = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
System.Diagnostics.Debug.WriteLine(uri2.Uri);
If you're testing this by making the call after restarting the app, during development, and you're rebuilding between launches that may be the cause, as rebuilding can change the app's identity and so be seen as a different client to the notification system.