Reputation: 2338
I'm using Quartz.net 2.2 installed as service. The jobs are stored in ms sql express, using AdoJobStore. The jobs are managed from an asp.net 4 website. Everything works fine, as expected: the service is running, the jobs are stored and triggered correctly. The problem that I'm facing is that, every day after 7am (this is when the application pool recycles) and I visit the site, it gives this error:
Object '/QuartzScheduler' has been disconnected or does not exist at the server.
[RemotingException: Object '/QuartzScheduler' has been disconnected or does not exist at the server.] System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +9443827 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +345 Quartz.Simpl.IRemotableQuartzScheduler.get_SchedulerName() +0 Quartz.Impl.RemoteScheduler.b__6(IRemotableQuartzScheduler x) +8 Quartz.Impl.RemoteScheduler.CallInGuard(Func`2 func) +61
[SchedulerException: Error communicating with remote scheduler.] Quartz.Impl.RemoteScheduler.CallInGuard(Func`2 func) +100 Quartz.Impl.RemoteScheduler.get_SchedulerName() +92 Quartz.Impl.SchedulerRepository.Bind(IScheduler sched) +65 Quartz.Impl.StdSchedulerFactory.Instantiate() +1815 Quartz.Impl.StdSchedulerFactory.GetScheduler() +102 ASP.global_asax.Application_Start(Object sender, EventArgs e) +241
[HttpException (0x80004005): Error communicating with remote scheduler.] System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9189101 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +131 System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +194 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +339 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +253
[HttpException (0x80004005): Error communicating with remote scheduler.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9104200 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256
After this, if I go to the server, and I stop/start Quartz.net service, then the site starts correctly.
Same thing occurs every time I upload via FTP the web.config modified, or another file modified which causes the website to restart. Here I obtain the same error, which I can circumvent stopping and restarting Quartz.net service.
Here is the global.asax of the website:
public static ISchedulerFactory SchedulerFactory;
public static IScheduler Scheduler;
void Application_Start(object sender, EventArgs e)
{
NameValueCollection p = new NameValueCollection();
p["quartz.scheduler.instanceName"] = "MyScheduler";
p["quartz.scheduler.proxy"] = "true";
p["quartz.threadPool.threadCount"] = "0";
p["quartz.scheduler.proxy.address"] = "tcp://localhost:555/QuartzScheduler";
SchedulerFactory = new StdSchedulerFactory(p);
Scheduler = SchedulerFactory.GetScheduler(); // <-- The exception seems to occur here
if (!Scheduler.IsStarted)
Scheduler.Start();
}
void Application_End(object sender, EventArgs e)
{
Scheduler.Shutdown(true);
}
Upvotes: 0
Views: 1365
Reputation: 2338
Since there have been no answers regarding this matter, I'm posting what I did:
Removing Scheduler.Shutdown(true);
from void Application_End
solves the issue that occured after application recycle.
If someone else has a better answer and explanation I'll mark it as answer.
Upvotes: 2
Reputation: 384
I have the approximately the same setup as you do :
However, I have never encountered this error. Below are the key parts of my code, I hope it helps :
Client parameters
NameValueCollection properties = new NameValueCollection();
properties["quartz.scheduler.instanceName"] = config.QuartzInstanceName;
properties["quartz.scheduler.instanceId"] = "AUTO";
properties["quartz.scheduler.proxy"] = "true";
properties["quartz.scheduler.proxy.address"] = "tcp://127.0.0.1:" + config.QuartzPort + "/" + config.QuartzInstanceName;
Host parameters
NameValueCollection properties = new NameValueCollection();
properties["quartz.scheduler.instanceName"] = config.QuartzInstanceName;
properties["quartz.scheduler.instanceId"] = "AUTO";
properties["quartz.scheduler.exporter.type"] = "Quartz.Simpl.RemotingSchedulerExporter, Quartz";
properties["quartz.scheduler.exporter.port"] = config.QuartzPort;
properties["quartz.scheduler.exporter.bindName"] = config.QuartzInstanceName;
properties["quartz.scheduler.exporter.channelType"] = "tcp";
properties["quartz.scheduler.exporter.channelName"] = "httpQuartz";
properties["jobStore.type"] = "Quartz.Simpl.RAMJobStore, Quartz";
Client initialization
// Note, this runs in an async loop, which keeps on trying to connect until it succeeds
// This is actually kinda ugly, needs to be refactored, but it works
while (mScheduler == null)
{
try
{
StdSchedulerFactory schedulerFactory = new StdSchedulerFactory(schedulerFactoryProps);
mScheduler = schedulerFactory.GetScheduler()
// Note that I do not use .Start() here
}
catch (Exception ex)
{
}
if (mScheduler == null)
Thread.Sleep(SCHEDULER_RETRY_DELAY);
}
Host initialization
StdSchedulerFactory schedulerFactory = new StdSchedulerFactory(schedulerFactoryProps);
mScheduler = schedulerFactory.GetScheduler();
mScheduler.Start();
Upvotes: 0