Using these libraries to connect to ews and get emails:
- "ews-javascript-api": "^0.10.3"
- "ews-javascript-api-auth": "^1.2.1"
Locally it works and I can connect to email boxes but when I run it on Jenkins I get this error:
SoapFaultDetails {
message: 'read ECONNRESET',
InnerException: null,
faultCode: null,
faultString: null,
faultActor: null,
responseCode: 127,
errorCode: 0,
exceptionType: null,
lineNumber: 0,
positionWithinLine: 0,
errorDetails: DictionaryWithStringKey {
keys: [],
keysToObjs: {},
objects: {},
keyPicker: [Function (anonymous)]
},
HttpStatusCode: undefined
}
A function which connects and read the email:
function getEws(user, password, host, subject) {
ews.ConfigurationApi.ConfigureXHR(new ewsAuth.ntlmAuthXhrApi(user, password))
const service = new ews.ExchangeService(ews.ExchangeVersion.Exchange2013_SP1)
service.Credentials = new ews.WebCredentials(user, password)
service.Url = new ews.Uri(host)
service
.SubscribeToStreamingNotifications(
[new ews.FolderId(ews.WellKnownFolderName.Inbox)],
ews.EventType.NewMail,
ews.EventType.Created,
ews.EventType.Deleted,
ews.EventType.Modified,
ews.EventType.Moved,
ews.EventType.Copied,
ews.EventType.FreeBusyChanged
)
.then(function (streamingSubscription) {
var connection = new ews.StreamingSubscriptionConnection(service, 1)
connection.AddSubscription(streamingSubscription)
connection.OnNotificationEvent.push(function (obj) {
ews.EwsLogging.Log(obj, true, true)
const searchFilter = new ews.SearchFilter.SearchFilterCollection(ews.LogicalOperator.And, [
new ews.SearchFilter.ContainsSubstring(ews.ItemSchema.Subject, subject)
])
const itemview = new ews.ItemView(1)
const foundItems = service.FindItems(ews.WellKnownFolderName.Inbox, searchFilter, itemview)
const adinationalProps = []
adinationalProps.push(ews.ItemSchema.TextBody)
foundItems.then(function (response) {
for (const item of response.Items) {
item
.Load(new ews.PropertySet(ews.BasePropertySet.FirstClassProperties, adinationalProps))
.then(function () {
fs.writeFileSync('cypress/fixtures/email.txt', item.TextBody.text)
})
.catch(error => {
console.log(' ----- Load error start ----- ')
console.error(error)
console.log(' ----- Load error end ----- ')
})
}
})
})
connection.OnDisconnect.push(function (connection, subscriptionErrorEventArgsInstance) {
ews.EwsLogging.Log(subscriptionErrorEventArgsInstance, true, true)
})
connection.Open()
})
.catch(error => {
console.log(' ----- SubscribeToStreamingNotifications error start ----- ')
console.error(error)
console.log(' ----- SubscribeToStreamingNotifications error end ----- ')
})
}
I would be grateful for any ideas on how to solve this issue on Jenkins.
CodePudding user response:
That was an issue with expired SSL certificates on Travis's side.