nmarus / node-ews

A simple JSON wrapper for the Exchange Web Services (EWS) SOAP API.
MIT License
116 stars 52 forks source link

ews.run() taking too long to return response. #101

Closed utkarsh13 closed 4 years ago

utkarsh13 commented 6 years ago

I am building an Alexa Skill which needs to fetch data from exchange server. When ews.run() is called from aws lambda, it takes too long to return response which leads to timeout of alexa. But when I call ews.run() from local machine, it returns response in about 1s.

Here is my code:

app.intent('SetOOO', {
    slots: {},
    utterances: ['set me as out of office today']
}, (req, res) => {
    return oofSetting.setOof().then((result) => {
        console.log("utkarsh" + result);
        res.say("Out of office setting saved successfully.");
    });
// exchange server connection info
const ewsConfig = {
    username: pass.userpass.user,
    password: pass.userpass.pass,
    host: pass.userpass.host,
    temp:__dirname+'\\WSDL'
};

// initialize node-ews
const ews = new EWS(ewsConfig);

// define ews api function
const ewsFunction = 'SetUserOofSettings';

// define ews api function args
const ewsArgs = {
    'Mailbox': {
        'Address': pass.userpass.email
    },
    'UserOofSettings': {
        OofState: 'Enabled',
        ExternalAudience: 'All',
        Duration: {
            StartTime: moment().startOf('day').format(),
            EndTime: moment().endOf('day').format()
        },
        InternalReply: {
            Message:'I am out of office today. Contact my manager for anything urgent.'
        },
        ExternalReply: {
            Message:'I am out of office today. Contact my manager for anything urgent.'
        }
    }
};
module.exports = {
    setOof: function() {
        console.log("utkarsh" + "setOof");
        return ews.run(ewsFunction, ewsArgs)
            .then((result) => {
                console.log("utkarsh" + JSON.stringify(result));
                return result;
            })
            .catch((err) => {
                console.log("utkarsh" + err.message);
            });
    }
};

Can someone tell me if I am doing anything wrong.

EDIT: Looks like there is an issue in opening .wsdl file while creating client from soap module.