I have a basic set up to send mails using nodemailer and NodeJS. I am using a gmail account to send it.
Everything is working perfectly when running on my local machine. I have a log that sends me an error message or a success message.
transporter.sendMail(mailOptions, function(err, data) {
if (err) {
console.log("Error " + err);
} else {
console.log("Email sent successfully");
}
});
The emails come successfully right when I receive the log, "Email sent successfully" when running everything on my local machine.
When I deploy it onto heroku and run the application, the emails come at random intervals. The email can come anywhere from 5 minutes after to a few hours later after receiving the "Email sent successfully" log in my heroku logs.
Could anyone help me figure out why there is such a big delay on my heroku app?
Related
I have a proactive messaging endpoint that works fine when a user is actively engaged in a conversation. For example, one use case where user asks for invoice data to be retrieved, which happens asynchronously and is sent back via proactive message. This works fine. But if a try to continue a conversation weeks later, the continueConversation action is failing. If I go into teams and initiate a new conversation with the bot, then resending the proactive message (without changing anything) works again.
In one of my use cases, the bot needs to follow up with the user 1+ weeks in the future. So I need to figure out how to send a proactive message to a teams user even if they haven't recently conversed with the bot. I'm not sure why continueConversation isn't working because the conversation ID doesn't change (and hasn't changed in months, probably not ever).
Here is the function I am using to send the proactive message.
server.post('/api/notify', async (req, res) => {
//console.log(req.body);
try {
const conversationReference = req.body.conversationReference;
await adapter.continueConversation(conversationReference, async turnContext => {
// If you encounter permission-related errors when sending this message, see
// https://aka.ms/BotTrustServiceUrl
await turnContext.sendActivity(req.body.message);
});
res.setHeader('Content-Type', 'text/html');
res.writeHead(200);
res.write('<html><body><h1>Proactive messages have been sent.</h1></body></html>');
res.end();
} catch (error) {
console.log('Bad Request. Please ensure your message contains the conversation reference and message text.');
console.log(error);
appInsightsClient.trackTrace({
message: `${error.name} - ${path.basename(__filename)}`,
severity: 4,
properties: {'error':error.message,'callStack':error.stack, 'botName': process.env.botName}
});
res.setHeader('Content-Type', 'text/html');
res.writeHead(400);
res.write('<html><body><p>Bad Request. Please ensure your message contains the conversation reference and message text.</p></body></html>');
res.end();
}
});
As the link in my own code says,
If your bot is restarted, a user awaiting a proactive message cannot receive it unless they have messaged the bot again after it restarted.
So that was exactly what the issue was. But the instructions on that page aren't giving the full details. You have to add the class via const { MicrosoftAppCredentials } = require('botframework-connector') as well as set the serviceUrl to pass (which is already available at conversationReference.serviceUrl).
So with these changes I added MicrosoftAppCredentials.trustServiceUrl(conversationReference.serviceUrl); before I send the proactive message and it started working fine even after bot was restarted.
My server is sending infinite mail with Laravel..
I tried testing a simple mail form, it returned a 404 and still sent a lot of e-mails. Now my server went crazy and is sending 14 e-mails per second on amazon SES.
I've tried:
restarting server
clearing the queue (no jobs are show in the database)
checking if retry has a limit, it is set to 3
went back to php5 (it was updated to 7 recently)
I'm using laravel 5.2.
My email sending logic:
\Mail::send('emails.contact', ['email_message' => $email_message, 'name' => $name], function($message) use ($to_email, $from_email, $name, $subject) {
$message->to($to_email)->from('my#server.com', $name)->replyTo($from_email, $name)->subject($subject);
});
PHP Log and Nginx logs shows no errors
Any ideas what I could do?
I am working on a chrome app which receives notification using GCM from a publisher. It is working just fine on linux. However when testing the app on a Mac OSX I never receive any messages even though the registration happen successfully. Nothing appears in the dev console, no exception.
function messageReceived(message) {
console.log("Message received: " + messageString);
}
chrome.gcm.onMessage.addListener(messageReceived);
console.log('App loaded')
Is there anyone experiencing the same problem?
With the newest beta version from sails.js (0.10.0-rc5) I'm trying to do this:
sails new Test
cd Test
sails generate api user
Create file assets/js/test.js
var socket = io.connect('http://localhost:1337');
socket.on('connect',function() {
console.log('connected');
socket.request('/user',{}, function(users) {
console.log(users);
});
socket.on('message', function(msg) {
console.log("Message: " + msg);
});
socket.on('user', function(msg) {
console.log("User: " + msg);
});
});
My problem
console.log("User: " + msg); and console.log("Message: " + msg); aren't receiving any messages when I create or update a user.
According to the documentation and to the Intro to sails.js video this socket.io messages should be send automatically.
What am I missing to successfully receive sails.js/socket.io message on my client?
If you installed the latest NPM version, then you'll also have the latest version of the Sails socket client. Check out its page on Github for basic usage, then check out the PubSub section of the Sails migration guide, which explains the differences between Sails v0.9.9x (which the Intro to Sails.js video shows) and the latest version. In the end, your code should look more like:
// Note--the latest sails socket client connects automatically!
// Get all of the existing users--also subscribes to socket events
// for those users
io.socket.get('/user', function serverResponded (body, sailsResponseObject) {
console.log(body);
});
// When a socket message about a user is received, display it
io.socket.on('user', function(data) {
console.log(data);
});
Notes
Pay special attention to the section in the migration guide about .watch(); it means that you don't get create events automatically anymore and have to subscribe to them in your server code using (for the User model) User.watch().
Remember that in general you don't get socket messages about actions that you yourself trigger, so if you want to test that your message-handling code is working, it's best to open up two windows (or tabs) and do your requests in one while watching for events in the other.
Also remember that you only get subscribed to socket events when you make a socket request; an AJAX call to /users will retrieve all of the current users, but you won't be subscribed to events. It has to be done using io.socket.get.
After successfully sent the URI to the web service from the push client, I send a toast notification from web service by using the URI, in web service I get the response as :
Push status 200,
NotificationStatus : Received,
DeviceConnectionStatus : Connected,
NotificationChannelStatus : Active.
But no message is received in the push client. The same scenario used to work fine earlier today. Can anyone tell me what is going wrong?
Is the message you are sending the same (ie. identical)? I seem to remember that some instances of a malformed message would get through the service OK, but then be suppressed on the device.
Do you have code to handle toast messages that arrive while your app is running? If you do, put a breakpoint in there and send a toast to the app while you're debugging and see what comes out. In this way you can make sure that the toast is making it to the device, and also see what the content is or what the problem might be.
channel.ShellToastNotificationReceived += channel_ShellToastNotificationReceived;
where channel is your channel object, and then
void channel_ShellToastNotificationReceived(object sender, NotificationEventArgs e)
{
Dispatcher.BeginInvoke(() => MessageBox.Show(e.Collection["wp:Text1"] + Environment.NewLine + e.Collection["wp:Text2"]));
}
or something similar to pop the message out to the display.
In web service, if a wrong setRequestProperty is set for example, setting wrong X-WindowsPhone-Target and wrong X-NotificationClass, then web service will receive notification received status, but the push client will not receive any message.
In my case I was sending a toast message with X-WindowsPhone-Target as token and X-NotificationClass as 1. After giving correct value it has started working fine.