简体   繁体   中英

iisnode encountered an error when processing the request. HRESULT: 0x6d HTTP status: 500 HTTP subStatus: 1013

I'm developing a webapp using ReactJS for the frontend and express for the backend. I'm deploying my app to azure.

To test if my requests are going through I wrote two different API requests.

The first one is very simple:

router.get('/test', (req, res) => {
  res.send('test was a success');
});

Then in the frontend I have a button which when clicked makes the request and I get the response 'test was a success'. This works every time.

The second test is:

router.post('/test-email', (req, res) => {
  let current_template = 'reset';
  readHTMLFile(__dirname + '/emails/' + current_template + '.html', function(err, html) {
    let htmlSend;
    let template = handlebars.compile(html);
    let = replacements = {
      name: req.body.name
    };
    htmlSend = template(replacements);
    let mailOptions = {
      from: 'email@email.com',
      to: 'someone@email.com',
      subject: 'Test Email',
      html: htmlSend
    };
    transporter.sendMail(mailOptions)
    .then(response => {
      res.send(response);
    })
    .catch(console.error);
   });
 });

Then when I've deployed the app I make a call to each one of these tests. The first one, like I mentioned always succeeds. The second one which is supposed to send a very simple email fails most of the time with the error "iisnode encountered an error when processing the request. HRESULT: 0x6d HTTP status: 500 HTTP subStatus: 1013". The strange thing is that every once in a while the email will send but this happens very rarely. Most times the request will take exactly two minutes before sending a response with an error.

I should note that when in development in localhost both tests work all the time with no issues whatsoever, it's only when in production (deployment to azure) that this happens.

I've been digging around for the last few days and came up with nothing. Any help or directions would be greatly appreciated.

I found out what the problem was. I'm using gmail to send my test emails, by default gmail will block any attempts to use an account if it thinks the app making the request is not secure. This can be easily fixed by simply clicking the link they automatically send you when you make your first attempt. What is not immediately obvious is when you go in production mode they add another level of security which in this case I believe is a captcha, and while you'll be able to send emails in development as soon as you deploy your app this no longer becomes the case.

Anyway, after digging around a little more I found the option to disable the captcha and now my emails send fine!

Link to that option https://accounts.google.com/b/0/DisplayUnlockCaptcha

Hopefully this will help someone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM