Windows Service not stopping, stuck at unsubscribing ews subscription

Specter123

The service acts like a mail watcher on a mail box and is working fine after installing on a new server. But, while stopping it, i get this error message that the

the service cannot accept control messages at this time

and all the ways to kill it didn't work. It gets stuck at removeSubscription() as per the logs.

public static void Unsubscribe ()
{
     if (_ss.Id.Length>0){
              Logger.log("Reached Here");
             _connection.RemoveSubscription(_ss);
       }
}

Here _ss is the streamingSubscription, _connection is streamingSubscriptionConnection references

Can you tell me how to fix it? P.S.: the same service works well on other server.

Specter123

Well, actually this function used to work really well on the previous server so had not used a try catch block to handle exceptions.

When i logged the exception, it turned out that it threw an error that the connection needs to be closed first. So changed the code to

_connection.close();
_connection.RemoveSubscription();

This solved the issue.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Windows Defender Service keeps stopping

Unsubscribing Multiple Subscription from Different Functions

Microsoft SharePoint Foundation Subscription Settings Service Application stuck on "Starting"

.NET Core Worker Service as Windows service not stopping after calling StopAsync

Angular6 rxjs unsubscribing to timer subscription OnDestroy does not work?

ManualResetEvent stopping socket program in windows service after sometime

Windows Service thread is not stopping in timely fashion in c#

Stopping Parallel.ForEach in Windows Service with below normal priority

Vagrant VM stuck in 'stopping' state

Windows Service Bus 1.1: looking for Powershell script to delete topic/subscription

Systemd service keeps stopping

Stopping a service from a socket

Background Service not Stopping Android

Why is the Docker service stopping?

Stopping a service that reads MSMQ

Audio service not stopping android

Stopping a service at specified time

EWS Push Subscription, how to know when it expires?

Stopping Mixpanel subscription with apps in the App Store

I have made a Windows service that "works" but is stuck in at starting up

Windows Service stuck on "starting" status as local system account

PHP-EWS stuck with curl 7.21.6

Windows Audio stopping intermittently

In windows, stopping postgres service causes node to crash with "error : terminating connection due to administrator command"

Is it possible to trigger a script execution when stopping a windows service from services.msc?

Wait for subscription in constructor of a Service

Unwanted subscription on observable service

RedisLabs Enterprise Cluster stopping the service

Stopping a service after Intent -Android