Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with @ewsjs/xhr and ews-javascript-api cann't read property of undefined #436

Open
MahmoudShaltoot opened this issue Apr 24, 2024 · 2 comments

Comments

@MahmoudShaltoot
Copy link

MahmoudShaltoot commented Apr 24, 2024

Hello!
I am trying to initialize calender folder object using ews.CalendarFolder.Bind(exch, ews.WellKnownFolderName.Calendar) but I get this error

TypeError: Cannot read properties of undefined (reading 'headers')
    at NtlmProvider.preCall (D:\TDRA\tra-gate-api\node_modules\@ewsjs\xhr\dist\ntlmProvider.js:48:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async XhrApi.xhr (D:\TDRA\tra-gate-api\node_modules\@ewsjs\xhr\dist\xhrApi.js:123:25

Here is the code

      // create instance
      let xhr = new XhrApi({rejectUnauthorized: false})
        .useNtlmAuthentication(credentials.userName, credentials.password);

      ews.ConfigurationApi.ConfigureXHR(xhr);

      var service = new ews.ExchangeService(ews.ExchangeVersion.Exchange2013);
      service.Credentials = new ews.WebCredentials(credentials.userName, credentials.password);
      service.Url = new ews.Uri(this.app.options['exchangeServiceUrl']);
      service.ImpersonatedUserId = new ews.ImpersonatedUserId(ews.ConnectingIdType.SmtpAddress, email)

      // Initialize the calendar folder object with only the folder ID.
      let calendar = await ews.CalendarFolder.Bind(service, ews.WellKnownFolderName.Calendar);
      ...

This issue occurs with ews.CalendarFolder.Bind(service, ews.WellKnownFolderName.Calendar);

PS: I tried to figure out what is the issue from the package I found that this request returns undefined

link: https://github.com/ewsjs/xhr/blob/a6265b03ba092c3712e27d9d3366bbf7add49ed3/src/ntlmProvider.ts#L54C31-L54C64

image

@gautamsi
Copy link
Owner

can you find out why err.response is undefined or would it be undefined all the time.

@MahmoudShaltoot
Copy link
Author

Hii @gautamsi, I found that there is a connectivity issue with exchange server, Axios throws an error with a message connect ETIMEDOUT 185.54.18.22:443

AxiosError: connect ETIMEDOUT 185.54.18.22:443 at AxiosError.from (D:\TDRA\tra-gate-api\node_modules\axios\dist\node\axios.cjs:836:14) at ClientRequest.handleRequestError (D:\TDRA\tra-gate-api\node_modules\axios\dist\node\axios.cjs:3086:25) at ClientRequest.emit (node:events:514:28) at TLSSocket.socketErrorListener (node:_http_client:501:9) at TLSSocket.emit (node:events:514:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) at Axios.request (D:\TDRA\tra-gate-api\node_modules\axios\dist\node\axios.cjs:3876:41) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async NtlmProvider.preCall (D:\TDRA\tra-gate-api\node_modules\@ewsjs\xhr\dist\ntlmProvider.js:43:30) at async XhrApi.xhr (D:\TDRA\tra-gate-api\node_modules\@ewsjs\xhr\dist\xhrApi.js:123:25) { port: 443, address: '185.54.18.22', syscall: 'connect', code: 'ETIMEDOUT', errno: -4039, ...

Can we throw an error here?

Thank you for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants