You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WellKnownFolderName sd = WellKnownFolderName.Inbox;
FolderId folderId = new FolderId(sd);
List<FolderId> folder = new ArrayList<FolderId>();
folder.add(folderId);
StreamingSubscription subscription = service.subscribeToStreamingNotifications(folder, EventType.NewMail);
StreamingSubscriptionConnection conn = new StreamingSubscriptionConnection(service, 30);
conn.addSubscription(subscription);
EventDelegate delegate = new EventDelegate(service);
conn.addOnNotificationEvent(delegate);
conn.addOnDisconnect(delegate);
conn.open();
EmailMessage msg = new EmailMessage(service);
msg.setSubject("Testing Streaming Notification on " + new Date());
msg.setBody(MessageBody.getMessageBodyFromText("Streaming Notification Test"));
msg.getToRecipients().add("someone@somewhere.com");
msg.send();
I get the following error:
microsoft.exchange.webservices.data.exception.ServiceRequestException: The request failed. Connection is still allocated
at microsoft.exchange.webservices.data.core.request.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:80)
at microsoft.exchange.webservices.data.core.request.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:160)
at microsoft.exchange.webservices.data.core.ExchangeService.internalCreateItems(ExchangeService.java:592)
at microsoft.exchange.webservices.data.core.ExchangeService.createItem(ExchangeService.java:651)
at microsoft.exchange.webservices.data.core.service.item.Item.internalCreate(Item.java:247)
at microsoft.exchange.webservices.data.core.service.item.EmailMessage.internalSend(EmailMessage.java:147)
at microsoft.exchange.webservices.data.core.service.item.EmailMessage.send(EmailMessage.java:258)
at test.TestEWS.main(TestEWS.java:287)
Caused by: java.lang.IllegalStateException: Connection is still allocated
at org.apache.http.util.Asserts.check(Asserts.java:34)
at org.apache.http.impl.conn.BasicHttpClientConnectionManager.getConnection(BasicHttpClientConnectionManager.java:248)
at org.apache.http.impl.conn.BasicHttpClientConnectionManager$1.get(BasicHttpClientConnectionManager.java:199)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:173)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at microsoft.exchange.webservices.data.core.request.HttpClientWebRequest.executeRequest(HttpClientWebRequest.java:291)
at microsoft.exchange.webservices.data.core.request.ServiceRequestBase.getEwsHttpWebResponse(ServiceRequestBase.java:780)
at microsoft.exchange.webservices.data.core.request.ServiceRequestBase.validateAndEmitRequest(ServiceRequestBase.java:719)
at microsoft.exchange.webservices.data.core.request.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:68)
... 7 more
I should note that this used to work in the past.
Continuing with some tests on this, creating a separate ExchangeService object for sending the email works. However, the following code still does not work.
StreamingSubscription subscription = service.subscribeToStreamingNotifications(folder, EventType.NewMail);
StreamingSubscriptionConnection conn = new StreamingSubscriptionConnection(service, 30);
conn.addSubscription(subscription);
conn.open();
subscription.unsubscribe();
if (conn.getIsOpen())
conn.close();
The line subscription.unsubscribe(); will still result in an "Connection is still allocated" error.
Also, if I comment it out, the line conn.close(); hangs.
For the following code:
I get the following error:
I should note that this used to work in the past.
Continuing with some tests on this, creating a separate ExchangeService object for sending the email works. However, the following code still does not work.
The line subscription.unsubscribe(); will still result in an "Connection is still allocated" error.
Also, if I comment it out, the line conn.close(); hangs.