Wcf + asp.net + multiple threads - asp.net

I have the following scenario:
A Service that does nothing but sleeps for the amount of time the WPF specifies through the WebRequest onject:
public class WorkerSvc : IWorkerSvc
{
#region IWorkerSvc Members
public void DoWork(int timeToSleep)
{
Trace.WriteLine(DateTime.Now.ToString() + "\tInside Stress Service with TimeToSleep: " + timeToSleep.ToString());
if (timeToSleep == 0)
return;
Thread.Sleep(timeToSleep * 1000);
Trace.WriteLine(DateTime.Now.ToString() + "\tThe Thread woke up.");
}
Then an aspx page (separate project) that calls into the service:
protected void Page_Load(object sender, EventArgs e)
{
System.Diagnostics.Trace.WriteLine(DateTime.Now.ToString() + " \tInside default stress web site page load;");
using (WorkerService.WorkerSvcClient client = new StressWebSite.WorkerService.WorkerSvcClient())
{
System.Diagnostics.Trace.WriteLine(DateTime.Now.ToString() + " \tCreated a new client of Stress WCF Service;");
var rowdata = Request.QueryString["SleepValue"];
System.Diagnostics.Trace.WriteLine(DateTime.Now.ToString() + " \tDetected Sleep Value in the Request: " + rowdata);
int realData = 0;
if (!string.IsNullOrEmpty(rowdata))
{
if (int.TryParse(rowdata, out realData))
{
System.Diagnostics.Trace.WriteLine(DateTime.Now.ToString() + " \tBefore Dowork() with SleepValue: " + realData);
client.DoWork(realData);
System.Diagnostics.Trace.WriteLine(DateTime.Now.ToString() + " \tAfter DoWork() with SleepValue: " + realData);
Response.Write(realData.ToString());
//Response.End();
}
}
}
}
A WPF Form That spanws a number of threads which essentially post some data to an aspx page:
private void PerformStress()
{
WebRequest request = WebRequest.Create(string.Concat(this.txtStressPageUrl.Text, "?", "SleepValue", "=", this.txtSleepValue.Text));
Trace.WriteLine("Created Web Request");
request.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
//return responseFromServer;
}
private void button3_Click(object sender, RoutedEventArgs e)
{
int stressThreadsCount = 0;
if (!int.TryParse(this.txtStressThreadCount.Text, out stressThreadsCount))
MessageBox.Show("Enter number of threads to stress");
ThreadStart start = delegate()
{
DispatcherOperation op = Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(PerformStress));
DispatcherOperationStatus status = op.Status;
while (status != DispatcherOperationStatus.Completed)
{
status = op.Wait(TimeSpan.FromMilliseconds(1000));
if (status == DispatcherOperationStatus.Aborted)
{
//
}
}
};
for (int i = 0; i < stressThreadsCount; i++)
{
var t = new Thread(start);
//this.runningThreads.Add(t);
t.Start();
//t.Join();
}
}
The problem is that it looks like eventhough I spawn several threads from the WPF side, to post to the aspx page, all the threads are processed in a serial manner, meaning each thread is waiting for the service to return.
I run this set up under cassiny.
I did not specify the WCF service's behavior to be a singleton.
Please help to ID the issue - I'd like to simulate multiple requests to the IIS and a page that calls into WCF to prove a concept.

Singleton will only affect how many objects will be created to service requests. By default, though, WCF services will only process a single request at a time. To change that, you should decorate your service implementation with
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]
For more info, see here: http://msdn.microsoft.com/en-us/library/system.servicemodel.concurrencymode.aspx

Related

Mosquitto client consuming is slowing down and data gap increasing

In a system with multiple devices, diagnostic data is published to separate topics for each device to Mosquitto Broker. A client application tries to consume data by subscribing to these topics separately for each device. The client receives 5 or 6 record per device per minute.
My problem is, after worker application started, the data received from Mosquitto Boroker starts to have delays on the client side. These delays start from 1 second, as time progresses, it lags behind by 1 day and 2 days during the time it is on. After stopping borker, the client continues to consume data.
Any ideas on what causes these delays?
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
string dataHost = _configuration.GetValue<string>("DataHost");
mqttClient = new MqttClient(dataHost);
mqttClient.MqttMsgPublishReceived += MqttClient_MqttMsgPublishReceived;
var list = _configuration.GetValue<string>("DeviceList").Split(',').ToList();
foreach (var deviceId in list)
{
mqttClient.Subscribe(
new string[] { $"{deviceId}/#" },
new byte[] { MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE });
}
mqttClient.ConnectionClosed += MqttClient_ConnectionClosed;
mqttClient.Connect("client", "username", "pass", false, 10);
}
private void MqttClient_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e)
{
try
{
var message = Encoding.UTF8.GetString(e.Message);
var messageArray = e.Topic.Split('/');
if (IsValidJson(message))
{
ItemValue itemValue = JsonConvert.DeserializeObject<ItemValue>(message);
_diagnosticRepository.InsertAsync(new DiagnosticDTO
{
value = messageArray[4].ToString(),
message = message,
messageTime = DateTime.Now,
deviceTime = itemValue.datetime,
sequenceNo = itemValue.sequenceNo,
});
}
}
catch (Exception ex)
{
_logger.LogError(ex.Message, "Consumer Insert Error");
}

asp.net timer not working

I am new to aspx and can not get my web timer to work. What am I missing here? Also DebugSet.logoutTime = 1800000 and DebugSet.logotWarnings = 3. The user is to be warned every minute before they are logged out of the system. These settings will be raised before the release, I just lowered them for testing purposes.
public partial class test : System.Web.UI.Page
{
private LoggedUser _User;
private Timer LogoutTimer;
private int TmCnt = 0;
protected void Page_Load(object sender, EventArgs e)
{
_User = new LoggedUser(true);
SetTimer();
}
private void SetTimer()
{
LogoutTimer = new Timer();
LogoutTimer.Interval = DebugSet.logoutTime/DebugSet.logoutWarnings;
LogoutTimer.Tick += new EventHandler<EventArgs>(LogoutTimer_Tick);
LogoutTimer.Enabled = true;
LogoutTimer.ViewStateMode = ViewStateMode.Enabled;
}
private void LogoutTimer_Tick(object sender, EventArgs e)
{
TmCnt++;
if (TmCnt == DebugSet.logoutWarnings)
{
_User.UserLoggedIn = false;
_User.SetSessions();
LogoutTimer.Enabled = false;
HttpContext.Current.Session["FCSWarning"] = "LoggedOut";
Response.Redirect("../Views/index.aspx");
}
else
{
int i = (DebugSet.logoutTime / (1000 * 60)) - ((DebugSet.logoutTime / (1000 * 60)) * TmCnt);
string msg = "<Script language=javascript>alert('You will be logged out in " + i.ToString() + " min. due to inactivity.');</Script>";
Response.Write(msg);
}
}
}
The ASP.NET Timer is an ASP.NET control. Each ASP.NET control must be added into a page control hierarchy, otherwise, it won't operate correctly or won't operate at all.
Add your Timer to page control hierarchy:
LogoutTimer = new Timer();
LogoutTimer.ID = "MyTimer";
this.Controls.Add(LogoutTimer);
LogoutTimer.Interval = DebugSet.logoutTime/DebugSet.logoutWarnings;
...
You are using a winforms timer (I think). With websites all instances of variables and classes are destroyed when the page is send to the browser (garbage collection). So LogoutTimer only exists for a very short time. You need to use the Timer control.
https://msdn.microsoft.com/en-us/library/bb386404.aspx
You should know this also when working with websites, the Page Life Cycle:
https://msdn.microsoft.com/en-us/library/ms178472.aspx

Sockets: .NET Core 2 server, HTML5 client cannot connect

I've run into a problem with socket server. Hope any of you might help me.
I have server built in .NET Core running on Debian which worked fine for clients made in .NET, but when I try to use HTML client it never gets past handshake.
Here's my example server:
class Program
{
public static TcpListener listener;
private static List<ClientPacket> clients;
private const int port = 4245;
private const int bufferSize = 1024;
static void Main(string[] args)
{
clients = new List<ClientPacket>();
listener = new TcpListener(IPAddress.Any, port);
listener.Start();
StartListening();
while (true)
{
}
}
private static void StartListening()
{
listener.BeginAcceptTcpClient(AcceptClient, listener);
}
private static void AcceptClient(IAsyncResult res)
{
TcpClient client = listener.EndAcceptTcpClient(res);
client.NoDelay = true;
ClientPacket packet = new ClientPacket(client);
clients.Add(packet);
Console.WriteLine("Client connected");
client.Client.BeginReceive(packet.buffer, 0, bufferSize, 0, new AsyncCallback(ReceiveMessage), packet);
StartListening();
}
private static void ReceiveMessage(IAsyncResult res)
{
ClientPacket packet = (ClientPacket)res.AsyncState;
Socket s = packet.client.Client;
try
{
if (s.EndReceive(res) > 0)
{
s.BeginReceive(packet.buffer, 0, bufferSize, 0, new AsyncCallback(ReceiveMessage), packet);
}
else
{
clients.Remove(packet);
s.Close();
packet = null;
}
}
catch (Exception e)
{
clients.Remove(packet);
s.Close();
packet = null;
}
}
It simply accepts clients, adds them to list and removes them after connection is lost. Problem is when I try it with this HTML5 client (copied from example tutorial):
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
function WebSocketTest()
{
if ("WebSocket" in window)
{
var ws = new WebSocket("ws://serverIP:4245");
ws.onopen = function()
{
ws.send("Message to send");
alert("Message is sent...");
};
ws.onmessage = function (evt)
{
var received_msg = evt.data;
alert("Message is received...");
};
ws.onclose = function()
{
alert("Connection is closed...");
};
window.onbeforeunload = function(event) {
socket.close();
};
}
else
{
alert("WebSocket NOT supported by your Browser!");
}
}
</script>
</head>
<body>
<div id="sse">
Run WebSocket
</div>
</body>
</html>
Problem is, that with this I never see alert from 'onopen' function so it's not opened properly and readystatus is kept as 'connecting' instead of 'connected' all the time.
I've read a about response from server with some hash to acknowledge and finish handshake, but seen it in older examples of .NET and not with this TcpListener from Core 2... so I thought it's a part of BeginAcceptTcpClient function... and since it worked with .NET client I'm not really sure where is mistake.
Can anybody help me with this or hint how to implement handshake hash response, please?
Ok I found a problem. Client really did expected a hash in response to finish handshake... still don't undeastand why HTML did and .NET Client didn't want it.
I've created a new method for handshake to send required response:
private static void CompleteHandshake(IAsyncResult res)
{
ClientPacket packet = (ClientPacket)res.AsyncState;
Socket s = packet.client.Client;
try
{
if (s.EndReceive(res) > 0)
{
var data = ByteArray.ReadString(packet.buffer);
if (new Regex("^GET").IsMatch(data))
{
Byte[] response = Encoding.UTF8.GetBytes("HTTP/1.1 101 Switching Protocols" + Environment.NewLine
+ "Connection: Upgrade" + Environment.NewLine
+ "Upgrade: websocket" + Environment.NewLine
+ "Sec-WebSocket-Accept: "
+ Convert.ToBase64String(
SHA1.Create().ComputeHash(
Encoding.UTF8.GetBytes(
new Regex("Sec-WebSocket-Key: (.*)").Match(data).Groups[1].Value.Trim() + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
)
)
) + Environment.NewLine
+ Environment.NewLine);
Console.WriteLine("Packet incoming");
s.Send(response, 0, response.Length, SocketFlags.None);
}
s.BeginReceive(packet.buffer, 0, bufferSize, 0, new AsyncCallback(ReceiveMessage), packet);
}
else
{
clients.Remove(packet);
s.Close();
packet = null;
}
}
catch (Exception e)
{
clients.Remove(packet);
s.Close();
packet = null;
}
}
Then the only change in old code is in listener method AcceptClient where simple change method parameter of BeginReceive to redirect onto CompleteHandshake.
private static void AcceptClient(IAsyncResult res)
{
TcpClient client = listener.EndAcceptTcpClient(res);
client.NoDelay = true;
ClientPacket packet = new ClientPacket(client);
clients.Add(packet);
client.Client.BeginReceive(packet.buffer, 0, bufferSize, 0, new AsyncCallback(CompleteHandshake), packet);
StartListening();
}
That new method CompleteHandshake after sending hash response will redirect back to the old ReceiveMessage method where you can handle message however you need.

Web Api or Web Service [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I read lots of about Web Api. For example i understand Web Service is a kind of Web Api or Web Api is more flexible.
But i didn't get that: Is Web Api future of Web Service?
For example one of our client needs data from our main database. Normally i use a Web Service for this -simple- purpose but this time i created a Web Api project. I got and service data plus i figured out how it works with Entity or Identity etc. But it's not simple as a web service. I think our client will think same thing also because of identity thing. So why should i prefer Web Api vs Web Service or should i prefer Web Api in this -simple- case?
This kind of depends what you mean by 'web service', but for now I'm going to assume you mean the old .net SOAP services.
If you are building something new today (September 2015) you are almost certainly better off using an asp.net web API. This is a standard REST-style service which can be called by almost any HTTP enabled client with no requirements for local software or understanding of how the service works, this is the whole point of the REST architectural style. I blogged a little about web API and REST here: http://blogs.msdn.com/b/martinkearn/archive/2015/01/05/introduction-to-rest-and-net-web-api.aspx
In your case of a simple service that adds CRUD operations to a database using entity framework. This can be very easily achieved with Web API. You can actually scaffold this whole thing based on a simple model.
To answer your specific question, Yes I believe that in eth asp.net world at least, web API is the future of web services. In fact web services have now been dropped in favour of web API.
Web API supports the .net identity model (I blogged on this here: http://blogs.msdn.com/b/martinkearn/archive/2015/03/25/securing-and-working-securely-with-web-api.aspx) and entity framework.
Hope this helps, if it does please mark as an answer or let me know of any more details you need.
public class Service1 : System.Web.Services.WebService
{
private List<string> GetLines(string filename) {
List<string> lines = new List<string>();
//filename: ime fajla (valute.txt) SA EXT
using (StreamReader sr = new StreamReader(Server.MapPath("podaci/" + filename))) {
string line;
while ((line = sr.ReadLine()) != null) {
lines.Add(line);
}
}
return lines;
}
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public double ProcitajKursNaDan(DateTime datum, string valuta) {
List<string> podaci = GetLines("valute.txt");
double kurs = 0.0;
// Pronalazenje upisa
for (int i = 0; i < podaci.Count; i++) {
string[] linija = podaci[i].Split('|');
/* Датум[0] | Oznaka valute[1] | Kurs[2] */
string dat = linija[0];
string val = linija[1];
string vrednost = linija[2];
// Uklanjanje viska
dat = dat.Trim();
val = val.Trim();
vrednost = vrednost.Trim();
// Konverzija:
DateTime datIzFajla = DateTime.ParseExact(dat, "d/M/yyyy", null);
double kursIzFajla = Convert.ToDouble(vrednost);
if (DateTime.Compare(datIzFajla, datum) == 0 && val == valuta)
kurs = kursIzFajla;
}
return kurs;
}
[WebMethod]
public bool UpisiKursNaDan(DateTime datum, string valuta, double Kurs) {
string date = datum.ToString("d/M/yyyy");
string linijaZaUpis = date + " | " + valuta + " | " + Kurs.ToString();
bool success = false;
try
{
StreamWriter sw = new StreamWriter(Server.MapPath("podaci/valute.txt"), true);
sw.WriteLine(linijaZaUpis);
sw.Close();
success = true;
}
catch {
success = false;
}
return success;
}
[WebMethod]
public List<string> ProcitajSveValute() {
List<string> linije = GetLines("valute.txt");
List<string> ValuteIzFajla = new List<string>();
for (int i = 0; i < linije.Count; i++) {
string linija = linije[i];
string valuta = linija.Split('|')[1];
valuta = valuta.Trim();
ValuteIzFajla.Add(valuta);
}
List<string> ValuteKraj = ValuteIzFajla.Distinct().ToList();
return ValuteKraj;
}
}
}
//using A10App.localhost;
//namespace A10App
//{
// public partial class pregledkursa : System.Web.UI.Page
// {
// protected void Page_Load(object sender, EventArgs e)
// {
// if (!this.IsPostBack) {
// Service1 servis = new Service1();
// List<string> valute = servis.ProcitajSveValute().ToList();
// for (int i = 0; i < valute.Count; i++)
// DropDownList1.Items.Add(valute[i]);
// }
// }
// protected void Button1_Click(object sender, EventArgs e)
// {
// string datum = TextBox1.Text;
// string valuta = DropDownList1.Text;
// Service1 servis = new Service1();
// double kurs = servis.ProcitajKursNaDan(DateTime.ParseExact(datum, "d/M/yyyy", null), valuta);
// if (kurs != 0.0)
// Label2.Text = kurs.ToString();
// else
// Label2.Text = "Nije pronadjen kurs";
// }
// }
//}
//namespace A10App
//{
// public partial class azuriranjeliste : System.Web.UI.Page
// {
// protected void Page_Load(object sender, EventArgs e)
// {
// if (!this.IsPostBack)
// {
// Service1 servis = new Service1();
// List<string> valute = servis.ProcitajSveValute().ToList();
// for (int i = 0; i < valute.Count; i++)
// DropDownList1.Items.Add(valute[i]);
// }
// }
// protected void Button1_Click(object sender, EventArgs e)
// {
// string datum = TextBox1.Text;
// string valuta = DropDownList1.Text;
// string kurs = TextBox2.Text;
// Service1 servis = new Service1();
// servis.UpisiKursNaDan(DateTime.ParseExact(datum, "d/M/yyyy", null), valuta, Convert.ToDouble(kurs));
// }
// }
//}

How to send a push notification to more than one device (iOS)?

I'm trying to optimize the push notifications on my server. For now I send those one by one (with an old library) and it takes a while (4 hours).
I refactored my service to send a notification with a lot of device tokens (For now I tried with batches of 500 tokens). For that I'm using the Redth/PushSharp library. I followed the sample code then I adapted it to send the notifications to severals device tokens.
PushService service = new PushService();
//Wire up the events
service.Events.OnDeviceSubscriptionExpired += new PushSharp.Common.ChannelEvents.DeviceSubscriptionExpired(Events_OnDeviceSubscriptionExpired);
service.Events.OnDeviceSubscriptionIdChanged += new PushSharp.Common.ChannelEvents.DeviceSubscriptionIdChanged(Events_OnDeviceSubscriptionIdChanged);
service.Events.OnChannelException += new PushSharp.Common.ChannelEvents.ChannelExceptionDelegate(Events_OnChannelException);
service.Events.OnNotificationSendFailure += new PushSharp.Common.ChannelEvents.NotificationSendFailureDelegate(Events_OnNotificationSendFailure);
service.Events.OnNotificationSent += new PushSharp.Common.ChannelEvents.NotificationSentDelegate(Events_OnNotificationSent);
service.Events.OnChannelCreated += new PushSharp.Common.ChannelEvents.ChannelCreatedDelegate(Events_OnChannelCreated);
service.Events.OnChannelDestroyed += new PushSharp.Common.ChannelEvents.ChannelDestroyedDelegate(Events_OnChannelDestroyed);
//Configure and start ApplePushNotificationService
string p12Filename = ...
string p12FilePassword = ...
var appleCert = File.ReadAllBytes(p12Filename);
service.StartApplePushService(new ApplePushChannelSettings(true, appleCert, p12FilePassword));
var appleNotification = NotificationFactory.Apple();
foreach (var itemToProcess in itemsToProcess)
{
itemToProcess.NotificationDateTime = DateTime.Now;
mobile.SubmitChanges();
string deviceToken = GetCleanDeviceToken(itemToProcess.MobileDevice.PushNotificationIdentifier);
appleNotification.ForDeviceToken(deviceToken);
}
service.QueueNotification(appleNotification
.WithAlert(itemsToProcess[0].MobileDeviceNotificationText.Text)
.WithSound("default")
.WithBadge(0)
.WithCustomItem("View", itemsToProcess[0].Value.ToString()));
//Stop and wait for the queues to drains
service.StopAllServices(true);
Then I tried to send 3 notifications to 2 devices. Only the first device got them (and the problem is not device-related because I tried with both of them separately).
Right after that an OperationCanceledException is thrown in the PushChannelBase class. So I don't know what's wrong. Any idea?
You should queue a separate notification for each item to process.
It is not possible set multiple device tokens on a single notification. The OperationCanceledException will occur, because you do.
Example: Console C# Application
This assumes
you have valid production and development certificates
you have stored multiple device tokens within your database
you have a notification that comes from your database
You are using PushSharp Library
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PushSharp;
using PushSharp.Core;
using PushSharp.Apple;
using System.IO;
namespace MyNotification
{
class Program
{
//args may take "true" or "false" to indicate the app is running for
//development or production (Default = false which means Development)
static void Main(string[] args)
{
bool isProduction = false;
if (args != null && args.Length == 1)
{
Console.Write(args[0] + Environment.NewLine);
bool.TryParse(args[0], out isProduction);
}
try
{
//Gets a notification that needs sending from database
AppNotification notification = AppNotification.GetNotification();
if (notification != null && notification.ID > 0)
{
//Gets all devices to send the above notification to
List<IosDevice> devices = IosDevice.GetDevices(!isProduction);
if (devices != null && devices.Count > 0)
{
PushBroker push = new PushBroker();//a single instance per app
//Wire up the events for all the services that the broker registers
push.OnNotificationSent += NotificationSent;
push.OnChannelException += ChannelException;
push.OnServiceException += ServiceException;
push.OnNotificationFailed += NotificationFailed;
push.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
push.OnChannelCreated += ChannelCreated;
push.OnChannelDestroyed += ChannelDestroyed;
//make sure your certifcates path are all good
string apnsCertFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../Certificate/Certificates_Apple_Push_Production.p12");
if (!isProduction)
apnsCertFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../Certificate/Certificates_Apple_Push_Development.p12");
var appleCert = File.ReadAllBytes(apnsCertFile);
push.RegisterAppleService(new ApplePushChannelSettings(isProduction, appleCert, "135TrID35")); //Extension method
foreach (IosDevice device in devices)
{
//if it is required to send additional information as well as the alert message, uncomment objects[] and WithCustomItem
//object[] obj = { "North", "5" };
push.QueueNotification(new AppleNotification()
.ForDeviceToken(device.DeviceToken)
.WithAlert(DateTime.Now.ToString())//(notification.AlertMessage)
//.WithCustomItem("Link", obj)
.WithBadge(device.BadgeCount + 1)
.WithSound(notification.SoundFile));//sound.caf
}
push.StopAllServices(waitForQueuesToFinish: true);
}
}
Console.WriteLine("Queue Finished, press return to exit...");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.ReadLine();
}
}
static void NotificationSent(object sender, INotification notification)
{
Console.WriteLine("Sent: " + sender + " -> " + notification);
}
static void NotificationFailed(object sender, INotification notification, Exception notificationFailureException)
{
Console.WriteLine("Failure: " + sender + " -> " + notificationFailureException.Message + " -> " + notification);
}
static void ChannelException(object sender, IPushChannel channel, Exception exception)
{
Console.WriteLine("Channel Exception: " + sender + " -> " + exception);
}
static void ServiceException(object sender, Exception exception)
{
Console.WriteLine("Service Exception: " + sender + " -> " + exception);
}
static void DeviceSubscriptionExpired(object sender, string expiredDeviceSubscriptionId, DateTime timestamp, INotification notification)
{
Console.WriteLine("Device Subscription Expired: " + sender + " -> " + expiredDeviceSubscriptionId);
}
static void ChannelDestroyed(object sender)
{
Console.WriteLine("Channel Destroyed for: " + sender);
}
static void ChannelCreated(object sender, IPushChannel pushChannel)
{
Console.WriteLine("Channel Created for: " + sender);
}
}
}

Resources