2017-11-16 3 views
0

私のNode.jsアプリケーションは、支払われたTwilio番号で受け取られたテキストメッセージに応答するように設定されています。私はngrokを使ってそれをテストし、すべてうまくいった。しかし、私がHerokuにアプリをデプロイすると、Twilioコンソールで11200 HTTPの検索に失敗したというエラーが表示され始めました。Twilio 11200 Heroku上のノードアプリケーションによるHTTP取得エラー

セットアップが必要なHerokuの設定がありますか?

// Twilio Credentials 
const accountSid = 'xxx'; 
const authToken = 'xxx'; 
const client = require('twilio')(accountSid, authToken); 
const MessagingResponse = require('twilio').twiml.MessagingResponse; 

var express = require('express'); 
var app = express(); 
var bodyparser = require('body-parser'); 

app.use(bodyparser.urlencoded({extended: true})); 

app.set('port', (process.env.PORT || 3000)); 

app.use('/', function(request, response){ 
response.send(); 
}); 

app.post('/sms', function(req, res) { 

const twiml = new MessagingResponse(); 

twiml.message('Hi, this is Culpability. Your incident has been logged. Your 
unique id # XXXX'); 

res.writeHead(200, {'Content-Type': 'text/xml'}); 
res.end(twiml.toString()); 

}); 

app.listen(app.get('port'), function() { 
// console.log('Node app is running on port', app.get('port')); 
}); 
+0

携帯電話のURLをHeroku URLに更新しましたか?例えば「curl」を使ってHeroku URLにアクセスできることをテストしましたか? – philnash

+0

URLをチェックしてカールしようとしますが、私はHeroku URLが他の方法で到達可能であることを確認しました! –

+0

あなたのアプリケーションのURLを電子メールで私と共有できますか?私は何を見つけることができますか?電子メールアドレスは[email protected] – philnash

答えて

0

ここではTwilioの開発者のエバンジェリストです。

私は問題が主に応答を送信するために使用している方法にあると思います。現在/smsルートのあなたの最後の行はres.end(twiml.toString());しかしResponse#end is used "to quickly end the response without any data."

である私は、res.writeHead()の使用があまりにも今時代遅れかもしれないと思います。

私はこのような何かにあなたの/smsのルートを変更します

app.post('/sms', function(req, res) { 
    const twiml = new MessagingResponse(); 
    twiml.message('Hi, this is Culpability. Your incident has been logged. Your unique id # XXXX'); 
    res.set('Content-Type', 'text/xml'); 
    res.status(200).send(twiml.toString()); 
}); 

はその後Herokuのに再配備しようとすると何が起こるかを参照してください。

関連する問題