EWS 在 Jenkins 上失败并显示 'read ECONNRESET'
EWS fails with 'read ECONNRESET' on Jenkins
使用这些库连接到 ews 并获取电子邮件:
- "ews-javascript-api": "^0.10.3"
- "ews-javascript-api-auth": "^1.2.1"
它在本地有效,我可以连接到邮箱,但是当我在 Jenkins 上 运行 它时,我收到此错误:
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
}
连接并阅读邮件的函数:
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 ----- ')
})
}
如有任何关于如何在 Jenkins 上解决此问题的想法,我将不胜感激。
这是 Travis 方面 SSL 证书过期的问题。
使用这些库连接到 ews 并获取电子邮件:
- "ews-javascript-api": "^0.10.3"
- "ews-javascript-api-auth": "^1.2.1"
它在本地有效,我可以连接到邮箱,但是当我在 Jenkins 上 运行 它时,我收到此错误:
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
}
连接并阅读邮件的函数:
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 ----- ')
})
}
如有任何关于如何在 Jenkins 上解决此问题的想法,我将不胜感激。
这是 Travis 方面 SSL 证书过期的问题。