RESOLVED: SMTP Time out in Rails app


#1

I have Rails app. I’ve set up a mailer for password resets. I previously was using Mandrill with the same setup (and different host/port/username/password configs). It worked just fine.

I’ve moved over to Hubspot transactional email. Here is my SMTP config:

I have generated a token with this curl command, as per the api docs:

curl -XPOST \
  -H "Content-Type: application/json" \
  -d '{"createdBy":"ops@happily.io","campaignName":"Password Reset Email"}' \
  https://api.hubapi.com/email/public/v1/smtpapi/tokens?hapikey=demo

I have triple checked that my username/password env vars are the same as the token JSON response.

I keep getting a timeout error and no email delivered:

heroku[router]: at=error
                code=H12 desc="Request timeout"
                method=POST
                path="/auth/password_resets"
                host=app.happily.io
                request_id=d8723348-cbf1-4e16-bedc-8d84bbf14406
                fwd="50.139.63.20"
                dyno=web.2
                connect=1ms
                service=30003ms
                status=503
                bytes=0
                protocol=https

 INFO -- : Completed 500 Internal Server Error in 60406ms (ActiveRecord: 18.7ms)
FATAL -- : Net::ReadTimeout (Net::ReadTimeout):

Any ideas why it’s timing out?


#2

@veganstraightedge At what point are you getting the timeout? When you are making the curl request you listed above?


#3

I only made the curl request once to get the token initially.

I’m getting the timeout in my server logs after hubspot is contacted but before it ever sends.


#4

@veganstraightedge are you using ?hapikey=demo or your own hapikey? I don’t believe the demo key would work for that.


#5

Where do I find my hapikey?


#6

Here you go!


#7

Ok. Went to there. Generated a real API key. Updated my mail.rb config settings. Tried it ou again. Got this error now.

This is really frustrating. Is there a time where you or a support engineer could screen pair with me and sort this out please? I’m guessing that y’all will be able to get me sorted out real quick like if we do it live. But this slow motion ping pong back and forth isn’t getting me there.

Thanks
Sb


#8

@veganstraightedge I can understand that the ping pong effect can be cumbersome. We are in the process of trying to convert this forum to have the resources to act closer to that of support. However at the moment this forum is not a support forum and we do not offer any type of screen pair/calling/etc.

Can you post the actual error response you are receiving from HubSpot instead of the rails error? If you are not receiving a response from HubSpot and solely a rails error then you might want to try stack overflow as I and my co-workers who help out here are likely not a rails expert. If you are getting any info from the HubSpot servers we would love to see it.


#9

The solution was to change my port from 465 to 587.

Apparently Rails uses SMARTTLS instead of TLS? Not totally sure.

But with 465 requests were just timing out. With 587, it Just Worked™.

¯_(ツ)_/¯