ews-javascript-api icon indicating copy to clipboard operation
ews-javascript-api copied to clipboard

Get SoapFaultDetails { message: 'read ECONNRESET', ..} on Jenkins

Open lkasianenko opened this issue 3 years ago • 2 comments
trafficstars

Get this error on Jenkins but locally it works 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 }

My Code `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 ----- ')
})

}`

lkasianenko avatar Dec 20 '21 10:12 lkasianenko

is jenkins killing the connection prematurely ?

gautamsi avatar Dec 20 '21 19:12 gautamsi

If you mean a connection with EWS, I don't know. Also, I added ews debug and got this error.

{ url: 'host', headers: { 'Content-Type': 'text/xml; charset=utf-8', Accept: 'text/xml', 'Accept-Encoding': 'gzip,deflate', Authorization: 'REDACTED' }, type: 'POST', data: '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"><soap:Header><t:RequestServerVersion Version="Exchange2013_SP1"></t:RequestServerVersion></soap:Header><soap:Body><m:FindItem Traversal="Shallow"><m:ItemShape><t:BaseShape>AllProperties</t:BaseShape></m:ItemShape><m:IndexedPageItemView MaxEntriesReturned="1" Offset="0" BasePoint="Beginning"></m:IndexedPageItemView><m:Restriction><t:Contains ContainmentMode="Substring" ContainmentComparison="IgnoreCase"><t:FieldURI FieldURI="item:Subject"></t:FieldURI><t:Constant Value="Lenovo Cloud Portal – New Account Details"></t:Constant></t:Contains></m:Restriction><m:ParentFolderIds><t:DistinguishedFolderId Id="inbox"></t:DistinguishedFolderId></m:ParentFolderIds></m:FindItem></soap:Body></soap:Envelope>' Error in calling service, error code:undefined

lkasianenko avatar Dec 20 '21 19:12 lkasianenko