EWS에서 여러 명의 명의 도용을 실행하고 각 사람의 일정 (가능한 100 명)에 대한 알림을 수신하려고 할 때 문제가 있습니다. 현재Exchange 웹 서비스 (EWS)의 여러 명의 명의 도용 스레드
나는 다른 모든 사용자를 가장 할 수있는 권한이는 Outlook 계정을 가지고, 모든 ExchangeService - 객체는이 자격 증명
계정 얻을짧은 버전입니다 나는 고유 ID를 통해 약속에 바인딩 할 때 그것은 하나의 스레드 만 실행하는 한 작동합니다. 자체 구독으로 새 Exchangeservice가 포함 된 새 스레드를 시작하면 Appointment.Bind() 요청에 대한 응답을받지 못합니다.
각각 하나의 스레드 만 사용하여 프로그램의 인스턴스 두 개를 실행하면 새로운 ExchangeService로 새 스레드를 시작하자마자 Appointment.Bind()가 응답을 제공하지 않습니다.
이상한 부분은 2 주일 전에 제대로 작동했지만 갑자기 작동이 멈췄으며 코드가 변경되지 않았습니다.
class Program
{
static void Main(string[] args)
{
var x = new OutlookListener("[email protected]");
var y = new OutlookListener("[email protected]");
new Thread(x.Start).Start();
new Thread(y.Start).Start();
while (true)
{
}
}
}
class OutlookListener
{
private ExchangeService _ExchangeService;
private AutoResetEvent _Signal;
public OutlookListener(string emailToImp)
{
_ExchangeService = new ExchangeService(ExchangeVersion.Exchange2010_SP1)
{
Credentials = new NetworkCredential("[email protected]", "password"),
Url = new Uri("exchangeUrl"),
ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, emailToImp)
};
}
public void Start()
{
var subscription = _ExchangeService.SubscribeToStreamingNotifications(new FolderId[] { WellKnownFolderName.Calendar },
EventType.Created);
var connection = CreateStreamingSubscription(_ExchangeService, subscription);
Console.Out.WriteLine("Subscription created.");
_Signal = new AutoResetEvent(false);
_Signal.WaitOne();
subscription.Unsubscribe();
connection.Close();
}
private StreamingSubscriptionConnection CreateStreamingSubscription(ExchangeService service, StreamingSubscription subscription)
{
var connection = new StreamingSubscriptionConnection(service, 30);
connection.AddSubscription(subscription);
connection.OnNotificationEvent += OnNotificationEvent;
connection.OnSubscriptionError += OnSubscriptionError;
connection.OnDisconnect += OnDisconnect;
connection.Open();
return connection;
}
private void OnNotificationEvent(object sender, NotificationEventArgs args)
{
// Extract the item ids for all NewMail Events in the list.
var newMails = from e in args.Events.OfType<ItemEvent>()
where e.EventType == EventType.Created
select e.ItemId;
foreach (var newMail in newMails)
{
var appointment= Appointment.Bind(_ExchangeService, newMail); //This is where I dont get a response!
Console.WriteLine(appointment.Subject);
}
}
private void OnSubscriptionError(object sender, SubscriptionErrorEventArgs args)
{
}
private void OnDisconnect(object sender, SubscriptionErrorEventArgs args)
{
}
}
어떤 제안 :
나는 내 문제의 빠른 데모를 만들었습니다?
Setting System.Net.ServicePointManager.DefaultConnectionLimit을 20으로 수정했습니다. :) – MojoDK