search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Connection Error when populating Daypilot scheduler

Asked by B
6 years ago.

Hi

We are using Daypilot MVC Scheduler. The scheduler will refresh using external code every 60 Sec. I am having some JSON Error if the connection drops.

I tried to capture the error and redirect as below

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Backend(string t)
{
try
{
return new Dps().CallBack(this);
}
catch (Exception)
{
return new SchedulerError().CallBack(this);
// return RedirectToAction("Login", "Account"); ;
}
}

class SchedulerError : DayPilotScheduler
{
protected override void OnInit(InitArgs e)
{
UpdateWithMessage("There is a Problem loading the scheduler. Please refresh the page!",CallBackUpdateType.None);
}
}

Any help would be really appriciated.

Thanks
B

Comment posted by B
6 years ago.

Any updates on this please Dan?

Comment posted by Dan Letecky [DayPilot]
6 years ago.

What kind of error is that - can you please post the error message?

Comment posted by B
6 years ago.

Hi Dan

Thanjks for your email. Normally we have issues when there is time out or unhandled exception on "return new Dps().CallBack(this);"

Sometime it could be authentication expiry

The error normally we get
"The request must start with 'JSON' string." on Deserialize.

Hope this helps.

Thanks
B

Answer posted by Dan Letecky [DayPilot]
6 years ago.

That should work if you replace OnInit with OnFinish.

OnInit is called once per page load, when the Scheduler is first displayed.

OnFinish is called at the end of every callback request.

Comment posted by B
6 years ago.

Hi Dan

I have tried as you asked and i still have the same problem. What I can see is when the network drops
string request = reader.ReadToEnd();
the request is empty (request is "")

I have attached detailed error message and screenshot with this.

Thanks
B

Comment posted by B
6 years ago.

Sorry I couldn't send any attachment, how do I share it please

Comment posted by Dan Letecky [DayPilot]
6 years ago.

Can you please send it to support@daypilot.org?

It looks like some misconfiguration of the server. Normally, if authentication fails (or expires) the request should be denied and you should see an error on the client side (e.g. HTTP 403 response). The target MVC action will not be executed at all.

In your case something seems to modify the request (the request body is stripped). You can also check the Network tab of the client browser (turn on the developer tools) to see how the request looks.

Comment posted by B
6 years ago.

Hi dan

I have sent an email as you requested.

I have shared via dropbox as well (support@daypilot.org)

https://www.dropbox.com/home?preview=Daypiloy+Error.doc

In the mean time, i will check the network tab.
Thanks
B

Comment posted by B
6 years ago.

Hi Dan

Checked the network tab, getting status 500 Error when calling backend

I have attached the screenshot in dropbox

https://www.dropbox.com/home?preview=Daypilot+Error+-+Newtwork+tab.doc

will also send you an email.

Thanks
B

Comment posted by Dan Letecky [DayPilot]
6 years ago.

Thanks. Can you please check what was the request body?

1. Click the line with the failed request to show the details.
2. In the request details on the right side, click the "Headers" tab.
3. Scroll down to "Request payload" section.

Here you can find the request body. I assume that it will be correctly formed, i.e. it will be a JSON string prepended with "JSON". It should look like this:

JSON{"action":"Init","type":"CallBack","header".....

If the request body is correct then something is intercepting the request on the server side and modifying it.

Comment posted by B
6 years ago.

Hi Dan

Thanks for your email. The payload has got valid JSON data, I have validated the data. Is there anything else I can check.

If there are any errors on callback, can we bind null value to scheduler (backend) grid, somehow the action result should accept null value.

Thanks
B

Comment posted by Dan Letecky [DayPilot]
6 years ago.

I think you should try to find why the request body gets cleared - because that's not normal.

If this is a result of a security check I would consider it a security weakness. If the authorization has expired the security framework must not let it through. Not to mention that modifying the request body is a bad practice. I don't believe this is by design. Most likely it's some kind of misconfiguration or bug in the project.

Check your web.config for modules, handlers and also Global.asax events - these all can intercept the request.

Comment posted by Dan Letecky [DayPilot]
6 years ago.

One more thing - reading the request body in one of the places I mentioned above would move the cursor position in the request input stream to the end. That might result in a symptom like this.

If you control that code you can reset the position like this:

Request.InputStream.Seek(0, System.IO.SeekOrigin.Begin);

Comment posted by B
6 years ago.

Hi Dan

Thanks for your email and help so far. I have gone back to my original code (not throwing any error and redirecting to dummy scheduler instance)

I have logged in as normal and disconnected the network to force the error (by refreshing the scheduler gird). I am getting following error.

Is there anyway we can error during call back, I refresh the grid every 60 secs (if there is network disruption for 15 secs it seems to be reconnecting).

It breaks in DaypilotScheduler.cs by foreach
private void LoadEvents()
{
Items = new List<Event>();

if (Events == null)
{
return;
}

List<RecurEx> recurExes = new List<RecurEx>();
List<RecurEvent> recurEvents = new List<RecurEvent>();

foreach (object dataItem in Events)
{
Event e = ParseDataItem(dataItem);

Trace

Server Error in '/' Application.

The network path was not found

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ComponentModel.Win32Exception: The network path was not found

Source Error:

Line 819: List<RecurEvent> recurEvents = new List<RecurEvent>();
Line 820:
Line 821: foreach (object dataItem in Events)
Line 822: {
Line 823: Event e = ParseDataItem(dataItem);

Source File: c:\Learning\Daypliot 8.3.5852\Source\DayPilotScheduler.cs Line: 821

Stack Trace:

[Win32Exception (0x80004005): The network path was not found]

[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +347
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +78
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +191
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +154
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +21
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +90
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +217
System.Data.SqlClient.SqlConnection.Open() +96
System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.<Open>b__36(DbConnection t, DbConnectionInterceptionContext c) +12
System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch(TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed) +72
System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext) +405
System.Data.Entity.Core.EntityClient.EntityConnection.<Open>b__2() +71
System.Data.Entity.SqlServer.<>c__DisplayClass1.<Execute>b__0() +15
System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func`1 operation) +190
System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation) +82
System.Data.Entity.Core.EntityClient.EntityConnection.Open() +271

[EntityException: The underlying provider failed on Open.]
System.Data.Entity.Core.EntityClient.EntityConnection.Open() +334
System.Data.Entity.Core.Objects.ObjectContext.EnsureConnection(Boolean shouldMonitorTransactions) +132
System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction(Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess) +46
System.Data.Entity.Core.Objects.<>c__DisplayClass7.<GetResults>b__5() +154
System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func`1 operation) +190
System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) +283
System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0() +15
System.Data.Entity.Internal.LazyEnumerator`1.MoveNext() +45
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +87
DayPilot.Web.Mvc.DayPilotScheduler.LoadEvents() in c:\Learning\Daypliot 8.3.5852\Source\DayPilotScheduler.cs:821
DayPilot.Web.Mvc.DayPilotScheduler.CallBack(Controller c) in c:\Learning\Daypliot 8.3.5852\Source\DayPilotScheduler.cs:550
NHS.ABMU.TOMS.TimeTable.Controllers.WeeklySessionsController.Backend(String t) in c:\Dev\NHS.ABMU.TOMS\Source\NHS.ABMU.TOMS.TimeTable\Controllers\WeeklySessionsController.cs:193
lambda_method(Closure , ControllerBase , Object[] ) +180
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +19
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +209
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +28
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +15
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +58
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +49
System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +57
System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +223
System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +15
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +58
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +49
System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +24
System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +102
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +58
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +44
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +15
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +16
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +58
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +54
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +16
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +58
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +44
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +12
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +16
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +58
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +44
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +11
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9644037
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

Comment posted by Dan Letecky [DayPilot]
6 years ago.

Ah, now I understand. You're breaking the connection between the web server and the SQL server. Well, that's a problem on its own.

However, the workaround would to be to place the Seek call before new SchedulerError().CallBack():

try 
{ 
  return new Dps().CallBack(this); 
} 
catch (Exception) 
{ 
  Request.InputStream.Seek(0, System.IO.SeekOrigin.Begin);
  return new SchedulerError().CallBack(this); 
} 
Comment posted by B
6 years ago.

Sorry Dan
I am still having same problem :(

Thanks
B

Comment posted by Dan Letecky [DayPilot]
6 years ago.

OK. Then you'll probably have to move the error-checking logic inside the Dps class where you load the event data.

You are using a collection that is evaluated lazily - i.e. it connects to the database when the items are accessed. Try accessing the first item in the collection (or otherwise check that the DB connection works) before assigning it to "Events" property. This way you'll be able to handle the exception in-place.

Comment posted by B
6 years ago.

That helps. Thanks for your help

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.