I am developing a web app where I use two hubs on a specific page to push notifications from server to clients and handle messages between clients. However I've come across a scenario oon my Azure production app service where the notifications hub won't transmit data back to the client even though the query is bringing the correct data.
Client code:
// Declare a proxy to reference the hub.
var notifHub = $.connection.NotificationHub;
var chat = $.connection.ChatHub;
var maxTabs = 10, index = 1;
// Start the connection.
$.connection.hub.start().done(function () {
notifHub.server.getNotifications();
/* Some more code irrelevant to this question */
});
notifHub.client.getNotifications = function (notification) {
// Html encode display name and message.
const notifications = JSON.parse(notification);
// Add the message to the page.
$("#Notifications").empty();
notifications.forEach(function (notification) {
const notificationDate = new Date(notification.CreationDate);
let alertColor = "";
if (((new Date) - notificationDate) < oneMinute)
alertColor = "alert-success";
else if (((new Date) - notificationDate) > oneMinute &&
((new Date) - notificationDate) < fiveMinutes)
alertColor = "alert-warning";
else if (((new Date) - notificationDate) > fiveMinutes)
alertColor = "alert-danger";
//language=html
var notificationTemplate = "<div class ='alert " + alertColor + "' role='alert' data-request-id='{{RequestId}}' data-connection-id='{{ConnectionId}}' data-requester='{{RequesterName}}' data-group-name='{{RequesterGroup}}' data-request-date-time='{{CreationDate}}'><strong>Usuario</strong>: {{RequesterName}}<br /><strong>Fecha</strong>: {{CreationDate | datetime}}</div>";
$("#Notifications").append(Mustache.render(notificationTemplate, notification));
});
};
Hub code
public void GetNotifications()
{
var db = new Entities();
db.Database.Log = s => Debug.WriteLine(s);
var companyId = Context.User.Identity.GetCompanyId();
var notifications = (from notification in db.AgentRequestNotification
where notification.AttendedByAgent == false && notification.CompanyId == companyId
orderby notification.CreationDate
select notification).ToList();
Clients.All.getNotifications(JsonConvert.SerializeObject(notifications));
}
Code works perfectly on my local environment as seen on the following screenshot
But not on production environment
On my Azure App settings I've enabled Websockets and disabled ARR Affinity. I've
debugged remotely with VS and this is the output I get, not sure what's causing about that WebSocketException shown after EF query log
Opened connection at 1/15/2018 9:03:46 PM +00:00
SELECT
[Project1].[RequestId] AS [RequestId],
[Project1].[ConnectionId] AS [ConnectionId],
[Project1].[RequesterName] AS [RequesterName],
[Project1].[RequesterGroup] AS [RequesterGroup],
[Project1].[AttendedByAgent] AS [AttendedByAgent],
[Project1].[CreationDate] AS [CreationDate],
[Project1].[CompanyId] AS [CompanyId],
[Project1].[AttendedByAgentDate] AS [AttendedByAgentDate]
FROM ( SELECT
[Extent1].[RequestId] AS [RequestId],
[Extent1].[ConnectionId] AS [ConnectionId],
[Extent1].[RequesterName] AS [RequesterName],
[Extent1].[RequesterGroup] AS [RequesterGroup],
[Extent1].[AttendedByAgent] AS [AttendedByAgent],
[Extent1].[CreationDate] AS [CreationDate],
[Extent1].[CompanyId] AS [CompanyId],
[Extent1].[AttendedByAgentDate] AS [AttendedByAgentDate]
FROM [dbo].[AgentRequestNotification] AS [Extent1]
WHERE (0 = [Extent1].[AttendedByAgent]) AND ([Extent1].[CompanyId] = #p__linq__0)
) AS [Project1]
ORDER BY [Project1].[CreationDate] ASC
-- p__linq__0: '1' (Type = Int32, IsNullable = false)
-- Executing at 1/15/2018 9:03:49 PM +00:00
-- Completed in 25 ms with result: SqlDataReader
Closed connection at 1/15/2018 9:03:49 PM +00:00
The thread 0x1520 has exited with code 0 (0x0).
The thread 0x2904 has exited with code 0 (0x0).
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.dll
Exception thrown: 'System.Net.WebSockets.WebSocketException' in System.Web.dll
Exception thrown: 'System.Net.WebSockets.WebSocketException' in mscorlib.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.dll
Exception thrown: 'System.Net.WebSockets.WebSocketException' in mscorlib.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.dll
Exception thrown: 'System.Net.WebSockets.WebSocketException' in System.Web.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in mscorlib.dll
Exception thrown: 'System.Net.WebSockets.WebSocketException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in EntityFramework.dll
Exception thrown: 'System.Net.WebSockets.WebSocketException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in EntityFramework.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
w3wp.exe Error: 0 : Error while closing the websocket: System.Net.WebSockets.WebSocketException (0x800704CD): An operation was attempted on a nonexistent network connection
at System.Web.WebSockets.WebSocketPipe.<>c__DisplayClass8_0.<WriteCloseFragmentAsync>b__0(Int32 hrError, Int32 cbIO, Boolean fUtf8Encoded, Boolean fFinalFragment, Boolean fClose)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.WebSockets.AspNetWebSocket.<>c__DisplayClass46_0.<<DoWork>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.WebSockets.AspNetWebSocket.<DoWork>d__45`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.WebSockets.AspNetWebSocket.<>c__DisplayClass32_0.<<CloseOutputAsyncImpl>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNet.SignalR.WebSockets.WebSocketHandler.<>c.<<CloseAsync>b__13_0>d.MoveNext()
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in EntityFramework.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in EntityFramework.SqlServer.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in Microsoft.Owin.Security.Cookies.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in Microsoft.Owin.Host.SystemWeb.dll
The thread 0x219c has exited with code 0 (0x0).
Here's the SignalR client log
[17:56:53 GMT-0500 (Eastern Standard Time)] SignalR: No hubs have been subscribed to. The client will not receive data from hubs. To fix, declare at least one client side function prior to connection start for each hub you wish to subscribe to.
[17:56:53 GMT-0500 (Eastern Standard Time)] ignalR: Negotiating with '/signalr/negotiate? clientProtocol=1.5&connectionData=%5B%5D'.
[17:56:53 GMT-0500 (Eastern Standard Time)] SignalR: webSockets transport starting.
[17:56:53 GMT-0500 (Eastern Standard Time)] SignalR: Connecting to websocket endpoint 'ws://samiweb.azurewebsites.net/signalr/connect? transport=webSockets&clientProtocol=1.5&connectionToken=yKn2ns1bOenZLiUtCiOSSfQg YCl%2FyVAvxKejSZx2x0svkyzIJJ85qjNMk7IBjy8Nes0Lg9W%2BUTAPW21z6rVHTwXbb4wxaZhVwn1J vzrNra0WhYCuXMiu6kLYs0FWuRUy&connectionData=%5B%5D&tid=1'.
[17:56:54 GMT-0500 (Eastern Standard Time)] SignalR: Websocket opened.
[17:56:54 GMT-0500 (Eastern Standard Time)] SignalR: webSockets transport connected. Initiating start request.
[17:56:54 GMT-0500 (Eastern Standard Time)] SignalR: The start request succeeded. Transitioning to the connected state.
[17:56:54 GMT-0500 (Eastern Standard Time)] SignalR: Now monitoring keep alive with a warning timeout of 13333.333333333332, keep alive timeout of 20000 and disconnecting timeout of 30000
[17:56:54 GMT-0500 (Eastern Standard Time)] SignalR: Invoking saminotificationhub.GetNotifications
[17:56:54 GMT-0500 (Eastern Standard Time)] SignalR: Invoked saminotificationhub.GetNotifications
Any help will be appreciated!
From your SignalR client log:
No hubs have been subscribed to. The client will not receive data from hubs. To fix, declare at least one client side function prior to connection start for each hub you wish to subscribe to.
AFAIK, the normal client log would look like: Client subscribed to hub 'notificationhub'. You could try to declare your client side methods prior to $.connection.hub.start().
Related
In the application I"m working with, there is some communication with the remote service using WCF (basic http binding, no fancy stuff). Since the client is lightweigh, the details of the server are irrelevant, you may assume that there is just a method that always return true (like ping or something).
The proxy is generated using a Task option, the new client instance is created each time the operation is called. Something like this could be spinning inside the timer:
void Foo()
{
var client = new PingServiceClient();
try
{
bool result = client.PingAsync().GetAwaiter().GetResult();
}
catch
{
//log something
}
finally
{
client.Abort();
}
}
My question is, how should I correctly handle the cases when the network is down? Because the behavior is different. I either get an application crashing (I assume on a task finalizer, which is for some reason not handled neither in AppDomain.CurrentDomain.UnhandledException nor in TaskScheduler.UnobservedTaskException), or sometimes it just silently outputs tons of error messages, but not crashing anything. Messages like these:
Exception thrown: 'System.Net.Sockets.SocketException' in System.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.ServiceModel.EndpointNotFoundException' in System.ServiceModel.dll
Exception thrown: 'System.ServiceModel.EndpointNotFoundException' in System.ServiceModel.Internals.dll
Exception thrown: 'System.ServiceModel.EndpointNotFoundException' in System.ServiceModel.Internals.dll
Exception thrown: 'System.ServiceModel.EndpointNotFoundException' in System.ServiceModel.Internals.dll
Exception thrown: 'System.ServiceModel.EndpointNotFoundException' in System.ServiceModel.Internals.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.dll
Exception thrown: 'System.AggregateException' in mscorlib.dll
I'm struggling to find a graceful way of handling these, so if anybody has some knowledge regarding this please share the approach.
Thanks in advance.
UPD:
I have tried to re-create the proxy with Begin/End pair and override the end method implementation in a partial class:
public partial class PingServiceClient : IPingServiceClient, PingService
{
public Task<bool> PingSync()
{
return Task.Factory.FromAsync(BeginPing(null, null), HandledEndPing);
}
private bool HandledEndPing(System.IAsyncResult result)
{
var res = false;
try
{
res = EndPing(result);
}
catch (Exception e)
{
;
}
return res;
}
}
Still the same barrage of messages in the output as before (the catch is working, though).
I have a self-hosted Katana OWIN service with windows authentication (no https), that publishes a SignalR hub. Everything is at latest NuGet level, net4.6.2. The hub is publishing log events from NLog.
I need to access this hub from a WPF client. Just to make sure, I have a simple javascript client also, which is getting the messages as needed. But the c# client "crashes".
At an unpredictable point in time I see this in output window:
Exception thrown: 'System.InvalidOperationException' in System.dll
Exception thrown: 'System.InvalidOperationException' in System.dll
Exception thrown: 'System.ObjectDisposedException' in System.dll
Exception thrown: 'System.ObjectDisposedException' in System.dll
Exception thrown: 'System.ObjectDisposedException' in mscorlib.dll
And from that point on the On event is not fired anymore, even if not a single message arrived before:
public static async Task<bool> ConnectAsync()
{
var settings = new Properties.Settings();
Connection = new HubConnection(settings.WebAPI);
Connection.Credentials = CredentialCache.DefaultNetworkCredentials;
HubProxy = Connection.CreateHubProxy("NLogHub");
HubProxy.On<DTO.WebApi.List.Log>("logEvent", (logEvent) => {
Debug.WriteLine(logEvent.TimeStamp);
//LogEventArrived?.Invoke(logEvent);
});
try
{
ServicePointManager.DefaultConnectionLimit = 10;
await Connection.Start(new LongPollingTransport());
Connection.EnsureReconnecting();
}
catch (HttpRequestException)
{
return false;
}
return true;
}
I have tried other transports too, but no luck. Does not matter what is in the On event - can be fully empty, this still happens.
Both client and server are running now on Windows 2016. but server will be Windows 2012, clients Windows 7 for now.
[Update 1]
The exception is thrown/not catched somewhere inside SignelR client code. Depending on transport this is what I can get:
LongPollingTransport
WebSocketTransport
After adding trace, I have some more details (WebSocketTransport), but still no idea how to handle:
13:48:04.9934736 - b3378218-e7f5-4ab4-89f6-08e6579bc70a - WS: OnMessage({})
13:48:10.1545908 - b3378218-e7f5-4ab4-89f6-08e6579bc70a - OnError(System.TimeoutException: Couldn't reconnect within the configured timeout of 00:00:30, disconnecting.)
13:48:10.1595862 - b3378218-e7f5-4ab4-89f6-08e6579bc70a - Disconnected
Exception thrown: 'System.Net.Sockets.SocketException' in mscorlib.dll
13:48:10.1675878 - b3378218-e7f5-4ab4-89f6-08e6579bc70a - Transport.Dispose(b3378218-e7f5-4ab4-89f6-08e6579bc70a)
Exception thrown: 'System.OperationCanceledException' in mscorlib.dll
13:48:10.2616468 - b3378218-e7f5-4ab4-89f6-08e6579bc70a - Closed
Exception thrown: 'System.OperationCanceledException' in mscorlib.dll
Exception thrown: 'System.OperationCanceledException' in mscorlib.dll
Exception thrown: 'System.OperationCanceledException' in System.dll
Exception thrown: 'System.OperationCanceledException' in mscorlib.dll
Exception thrown: 'System.OperationCanceledException' in mscorlib.dll
As I mentioned before: the JavaScript client is working like a charm.
[Update 2]
All transports complain about n ot being able to reconnect. But nothing points on a connection lost. How to debug that?
Any idea is appreciated...
I using this code (where context is OAuthGrantCustomExtensionContext):
var userManager = context.OwinContext.GetUserManager<ApplicationUserManager>();
ApplicationUser appUser1 = await userManager.FindByIdAsync("My user id"); // 31 seconds to execute
ApplicationUser appUser2 = await userManager.FindByIdAsync("My user id"); // 1 milisecond to execute
The execution of the function FindByIdAsync takes 31 seconds on the first time. On the second execution it's takes only <1 MS. I also checked how fast is my DB by running a "SELECT... WHERE..." query - and it's really fast - <1 MS.
I also noticed in this output inside the "Output Window":
Exception thrown: 'System.Data.SqlClient.SqlException' in
System.Data.dll Exception thrown: 'System.Data.SqlClient.SqlException'
in System.Data.dll Exception thrown:
'System.Data.SqlClient.SqlException' in System.Data.dll Exception
thrown: 'System.Data.SqlClient.SqlException' in System.Data.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in
System.Data.dll Exception thrown: 'System.Data.SqlClient.SqlException'
in System.Data.dll Exception thrown:
'System.Data.SqlClient.SqlException' in System.Data.dll Exception
thrown: 'System.Data.SqlClient.SqlException' in System.Data.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in
System.Data.dll Exception thrown: 'System.Data.SqlClient.SqlException'
in System.Data.dll Exception thrown:
'System.Data.SqlClient.SqlException' in System.Data.dll Exception
thrown: 'System.Data.SqlClient.SqlException' in System.Data.dll The
thread 0x1598 has exited with code 0 (0x0). Exception thrown:
'System.Data.SqlClient.SqlException' in System.Data.dll Exception
thrown: 'System.Data.SqlClient.SqlException' in System.Data.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in
System.Data.dll Exception thrown: 'System.Data.SqlClient.SqlException'
in System.Data.dll Exception thrown:
'System.Data.SqlClient.SqlException' in System.Data.dll Exception
thrown: 'System.Data.SqlClient.SqlException' in System.Data.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in
System.Data.dll Exception thrown: 'System.Data.SqlClient.SqlException'
in System.Data.dll Exception thrown:
'System.Data.SqlClient.SqlException' in System.Data.dll Exception
thrown: 'System.Data.SqlClient.SqlException' in System.Data.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in
System.Data.dll Exception thrown: 'System.Data.SqlClient.SqlException'
in System.Data.dll Exception thrown:
'System.Data.Entity.Infrastructure.RetryLimitExceededException' in
EntityFramework.dll 'iisexpress.exe' (CLR v4.0.30319:
/LM/W3SVC/6/ROOT-1-131126169736320764): Loaded
'EntityFrameworkDynamicProxies-EntityFramework'. Exception thrown:
'System.Data.SqlClient.SqlException' in System.Data.dll Exception
thrown: 'System.Data.SqlClient.SqlException' in System.Data.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in
System.Data.dll Exception thrown: 'System.Data.SqlClient.SqlException'
in System.Data.dll Exception thrown:
'System.Data.Entity.Core.EntityCommandExecutionException' in
EntityFramework.dll Exception thrown:
'System.Data.Entity.Core.EntityCommandExecutionException' in
EntityFramework.dll Exception thrown:
'System.Data.Entity.Core.EntityCommandExecutionException' in
EntityFramework.dll Exception thrown:
'System.Data.Entity.Core.EntityCommandExecutionException' in
EntityFramework.dll 'iisexpress.exe' (CLR v4.0.30319:
/LM/W3SVC/6/ROOT-1-131126169736320764): Loaded
'EntityFrameworkDynamicProxies-ObjectModelLayer'. 'iisexpress.exe'
(CLR v4.0.30319: /LM/W3SVC/6/ROOT-1-131126169736320764): Loaded
'EntityFrameworkDynamicProxies-Microsoft.AspNet.Identity.EntityFramework'.
The output above is collected from the time my machine executed this line:
ApplicationUser appUser1 = await userManager.FindByIdAsync("My user id");
In the other lines of code, the Output Window was empty. (which can explain why they was so fast).
As you can see, alot of SqlException are thrown while this code line. It's seems to me like a "retry" mechanism that try agian and agian to execute some logic but it failed. I woundering if this is the reason why this taking so long?
I looking for:
Way to see exectly what is this SqlException? maybe I'll fix this and this code will run faster.
How to fix the FindByIdAsync to make it work fast (<5 seconds) every time?
Thank you for support!
UPDATE
I found a useful way to catch first chance exceptions. With this code:
AppDomain.CurrentDomain.FirstChanceException +=
(object source, FirstChanceExceptionEventArgs e) =>
{
Console.WriteLine("FirstChanceException event raised in {0}: {1}", AppDomain.CurrentDomain.FriendlyName, e.Exception.Message);
};
So, I ran the code and collected the thrown exceptions. Got the following exception for 18 times:
The server principal "XXX" is not able to access the database "master"
under the current security context. Database 'master' on server
'XXX.net' is not currently available. Please retry the connection
later. If the problem persists, contact customer support, and provide
them the session tracing ID of 'XXXXXXX-68E9-4FDD-9E3D-92BE27438835'.
Login failed for user 'XXX'.
My user is really not allowed to access the "master" table. So, it's make sense. I change my DB connection string to another user with permission to access the "master" table - and now it's working fast! (less then 3 seconds).
After giving the right permissions, I still got this exception in the log (for 7 times):
Invalid object name 'dbo.EdmMetadata'.
Questions:
I don't understand why the function FindByIdAsync need to access the master table???
How to fix the error "Invalid object name 'dbo.EdmMetadata'."?
6 years later, I am still getting similar behavior with the latest libraries for Identity and Entity-Framework. The first call to userManager.Get[Something] takes about 5 seconds; subsequent calls are 3-10 milliseconds.
Could it be that Identity is trying to check/recreate the underlying database on the first call?
This is the method i am using.
try
{
List<Patient> pList = await App.MobileService.GetTable<Patient>().Where(
patient => patient.id == 1).ToListAsync();
foreach (Patient p in pList)
{
System.Diagnostics.Debug.WriteLine("{0}, {1}", p.id, p.first_name);
}
}
catch (Exception err)
{
System.Diagnostics.Debug.WriteLine("ERROR! : {0}", err.Message);
}
Here's the Patient entity.
class Patient
{
public int id { get; set; }
public string first_name { get; set; }
public string last_name { get; set; }
public string middle_name { get; set; }
public string nirc { get; set; }
public int bed_id { get; set; }
}
Here's the error i am getting.
An exception of type 'System.Net.WebException' occurred in System.Windows.ni.dll and wasn't handled before a managed/native boundary
An exception of type 'System.Net.WebException' occurred in System.Windows.ni.dll and wasn't handled before a managed/native boundary
An exception of type 'System.Net.WebException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
An exception of type 'Newtonsoft.Json.JsonReaderException' occurred in Newtonsoft.Json.DLL and wasn't handled before a managed/native boundary
An exception of type 'Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException' occurred in Microsoft.Azure.Zumo.WindowsPhone8.Managed.DLL and wasn't handled before a managed/native boundary
An exception of type 'Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
An exception of type 'Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
An exception of type 'Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
A first chance exception of type 'Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException' occurred in mscorlib.ni.dll
An exception of type 'Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
When i wrap my method within a TryCatch, i get this message
Error : The request could not be completed. ()
Here's the stack error message
at Microsoft.WindowsAzure.MobileServices.MobileServiceClient.CreateMobileServiceException(String errorMessage, IServiceFilterRequest request, IServiceFilterResponse response)
at Microsoft.WindowsAzure.MobileServices.MobileServiceClient.ThrowInvalidResponse(IServiceFilterRequest request, IServiceFilterResponse response, JToken body)
at Microsoft.WindowsAzure.MobileServices.MobileServiceClient.<RequestAsync>d__f.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.WindowsAzure.MobileServices.MobileServiceTable.<SendReadAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.WindowsAzure.MobileServices.MobileServiceTable`1.<EvaluateQueryAsync>d__3`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.WindowsAzure.MobileServices.MobileServiceTableQuery`1.<ToListAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at PhoneApp1.MainPage.<populate>d__0.MoveNext()
A few points to note.
Permission is set to Anybody with the Application Key
I've added reference to Windows Azure Mobile Services Managed Client
I've already inserted this code within App.XAML.CS. using Microsoft.WindowsAzure.MobileServices;
I've already placed this piece of code acquired from this website within App.XAML.CS.
public static MobileServiceClient MobileService = new MobileServiceClient( AppUrl, AppKey );
Why am i unable to connect to my database? I've tried running these codes on a Windows Store Application and it worked. Previously i've done the exact same thing and it worked as well.
This link saved me.
Apparently, all i had to do is to change the service address from https to http. So instead of this,
public static MobileServiceClient MobileService = new MobileServiceClient(
"https://www.example.azure-mobile.net/",
"fjkdslajkfdlsref31321fgdsat34ajklfdslajfkldsa"
);
Change it to
public static MobileServiceClient MobileService = new MobileServiceClient(
"http://www.example.azure-mobile.net/",
"fjkdslajkfdlsref31321fgdsat34ajklfdslajfkldsa"
);
Problem solved.
Check the date / time on your computer or the device. In my case I had powered on a dev phone that had been off for some time and the date / time was completely wrong. While changing the endpoint from HTTPS to HTTP does work around the issue, for me the proper solution was to keep HTTPS and fix the date / time on the device.
I solved this problem in my Android devices. You will need kill your app instance, change the system date/time to current and reopen the app.
Thanks Nathanial Woolls!!!
I can't comment because of my low reputation, I'm experiencing the same problem, but it's inconsistent.
If I try to use the registration page on my app that hits an Azure Mobile Service, sometimes it times out with the same error ("The request could not be completed. ()"), then if I try again immediately it works fine.
I'm using an actual Windows Phone Device and it's connected using Wi-Fi provided by my iPhone's hotspot which is actually 4G so there's definitely not a connection issue.
I read other articles that said there's no point trying to check if an internet connection is available, just try and send the data and deal with any issues. I deal with the issue but the issue shouldn't be happening.
Did you experience any more problems?
I've tried using https and http for the MobileService connection, doesn't seem to make any difference.
In case anyone else runs into this, I experienced the same issue when I simply had simply passed a URL with an incorrect subdomain to MobileServiceClient.
For instance, something like this:
public static MobileServiceClient MobileService = new MobileServiceClient(
"http://www.example.azure-mobile.net/",
"fjkdslajkfdlsref31321fgdsat34ajklfdslajfkldsa"
);
Make sure that also this is turned off.
I have a WPF application that will attempt to get data from a web service (ASMX). I have made a method on the web service to see if the web service is available. I cannot however, catch the exception i get returned. Here is my code that calls the test method on the web service:
public bool TestConnection()
{
try
{
return service.Test();
}
catch(Exception ex)
{
return false;
}
}
The service.Test() method throws an exception because there is no web service listening there (i changed the url to mimic a real scenario). The exception it throws is not getting caught by my catch statement. And i cannot figure out why not. This is the exception i get:
System.Windows.Markup.XamlParseException occurred
Message='The invocation of the constructor on type 'GreenWebPlayerWPF.Window1' that matches the specified binding constraints threw an exception.' Line number '4' and line position '258'.
Source=PresentationFramework
LineNumber=4
LinePosition=258
StackTrace:
at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
InnerException:
Message=Exception handled
Source=Player
StackTrace:
at GreenWebPlayerWPF.Services.GWDSServiceProxy.Test() in C:\Subversion\GreenWeb 2.5\Version 2.5\GreenWebPlayerWPF\Services\Proxy\GWDSServiceProxy.cs:line 214
at GreenWebPlayerWPF.HeartBeatService.Start() in C:\Subversion\GreenWeb 2.5\Version 2.5\GreenWebPlayerWPF\Services\HeartBeatService.cs:line 21
at GreenWebPlayerWPF.Window1..ctor() in C:\Subversion\GreenWeb 2.5\Version 2.5\GreenWebPlayerWPF\Window1.xaml.cs:line 127
InnerException:
Message=Service unavailable:Unable to connect to the remote server
Source=Player
StackTrace:
at GreenWebPlayerWPF.Services.GWDSServiceProxy.Test() in C:\Subversion\GreenWeb 2.5\Version 2.5\GreenWebPlayerWPF\Services\Proxy\GWDSServiceProxy.cs:line 206
InnerException:
The exception is a xaml exception, and i seems my exception is bubbling up, before i get a chance to catch it...
Anyone know what is going on?