2017-05-17 1 views
0

Verwenden von Heroku zum Hosten einer Sinatra-App. Ich habe eine Route, die eine SMS senden soll. Es gibt stattdessen einen 500 internen Serverfehler zurück.500 Interner Serverfehler Versuch, eine SMS mit Twilio zu senden

Alles funktioniert einwandfrei in localhost. Die Protokolle zeigen einen Twilio :: REST :: RequestError.

main.rb

post '/sms/send' do 

    @client = Twilio::REST::Client.new account_sid, auth_token 

    @client.account.messages.create(
     from: '+xxxxxxxxxxx', 
     to: '+xxxxxxxxxxx', 
     body: 'Robot invasion! Reply back with any sightings.' 
    )  
end 

Logs:

2017-05-17T19:04:24.640120+00:00 heroku[router]: at=info method=POST path="/sms/send" host=dysfunctionalapp.herokuapp.com request_id=a3736f1a-2264-4b91-b0a9-a3bde94342bd fwd="216.73.77.194" dyno=web.1 connect=0ms service=22ms status=500 bytes=255 protocol=https 
2017-05-17T19:04:24.639060+00:00 app[web.1]: 2017-05-17 19:04:24 - Twilio::REST::RequestError - Twilio::REST::RequestError: 
2017-05-17T19:04:24.639072+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/twilio-ruby-4.13.0/lib/twilio-ruby/rest/base_client.rb:125:in `connect_and_send' 
2017-05-17T19:04:24.639074+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/twilio-ruby-4.13.0/lib/twilio-ruby/rest/base_client.rb:55:in `block (2 levels) in <class:BaseClient>' 
2017-05-17T19:04:24.639075+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/twilio-ruby-4.13.0/lib/twilio-ruby/rest/list_resource.rb:94:in `create' 
2017-05-17T19:04:24.639076+00:00 app[web.1]: /app/main.rb:84:in `block in <top (required)>' 
2017-05-17T19:04:24.639078+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1632:in `call' 
2017-05-17T19:04:24.639078+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1632:in `block in compile!' 
2017-05-17T19:04:24.639079+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:991:in `block (3 levels) in route!' 
2017-05-17T19:04:24.639095+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1010:in `route_eval' 
2017-05-17T19:04:24.639096+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:991:in `block (2 levels) in route!' 
2017-05-17T19:04:24.639097+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1037:in `block in process_route' 
2017-05-17T19:04:24.639097+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1035:in `catch' 
2017-05-17T19:04:24.639098+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1035:in `process_route' 
2017-05-17T19:04:24.639099+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:989:in `block in route!' 
2017-05-17T19:04:24.639099+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:988:in `each' 
2017-05-17T19:04:24.639100+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:988:in `route!' 
2017-05-17T19:04:24.639101+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1094:in `block in dispatch!' 
2017-05-17T19:04:24.639101+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `block in invoke' 
2017-05-17T19:04:24.639102+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `catch' 
2017-05-17T19:04:24.639102+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `invoke' 
2017-05-17T19:04:24.639103+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1091:in `dispatch!' 
2017-05-17T19:04:24.639104+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:923:in `block in call!' 
2017-05-17T19:04:24.639105+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `block in invoke' 
2017-05-17T19:04:24.639105+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `catch' 
2017-05-17T19:04:24.639106+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `invoke' 
2017-05-17T19:04:24.639106+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:923:in `call!' 
2017-05-17T19:04:24.639107+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:913:in `call' 
2017-05-17T19:04:24.639108+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/rack-protection-2.0.0/lib/rack/protection/xss_header.rb:18:in `call' 
2017-05-17T19:04:24.639108+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/rack-protection-2.0.0/lib/rack/protection/path_traversal.rb:16:in `call' 
2017-05-17T19:04:24.639109+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/rack-protection-2.0.0/lib/rack/protection/json_csrf.rb:26:in `call' 
2017-05-17T19:04:24.639110+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/rack-protection-2.0.0/lib/rack/protection/base.rb:50:in `call' 
2017-05-17T19:04:24.639110+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/rack-protection-2.0.0/lib/rack/protection/base.rb:50:in `call' 
2017-05-17T19:04:24.639111+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/rack-protection-2.0.0/lib/rack/protection/frame_options.rb:31:in `call' 
2017-05-17T19:04:24.639112+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.3/lib/rack/logger.rb:15:in `call' 
2017-05-17T19:04:24.639113+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.3/lib/rack/common_logger.rb:33:in `call' 
2017-05-17T19:04:24.639113+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:231:in `call' 
2017-05-17T19:04:24.639114+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:224:in `call' 
2017-05-17T19:04:24.639114+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.3/lib/rack/head.rb:12:in `call' 
2017-05-17T19:04:24.639115+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.3/lib/rack/method_override.rb:22:in `call' 
2017-05-17T19:04:24.639116+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:194:in `call' 
2017-05-17T19:04:24.639116+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1955:in `call' 
2017-05-17T19:04:24.639117+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1499:in `block in call' 
2017-05-17T19:04:24.639118+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1726:in `synchronize' 
2017-05-17T19:04:24.639118+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1499:in `call' 
2017-05-17T19:04:24.639125+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/thin-1.7.0/lib/thin/connection.rb:86:in `block in pre_process' 
2017-05-17T19:04:24.639125+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/thin-1.7.0/lib/thin/connection.rb:84:in `catch' 
2017-05-17T19:04:24.639126+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/thin-1.7.0/lib/thin/connection.rb:84:in `pre_process' 
2017-05-17T19:04:24.639127+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/thin-1.7.0/lib/thin/connection.rb:53:in `process' 
2017-05-17T19:04:24.639127+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/thin-1.7.0/lib/thin/connection.rb:39:in `receive_data' 
2017-05-17T19:04:24.639129+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/eventmachine-1.2.3/lib/eventmachine.rb:194:in `run_machine' 
2017-05-17T19:04:24.639130+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/eventmachine-1.2.3/lib/eventmachine.rb:194:in `run' 
2017-05-17T19:04:24.639130+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/thin-1.7.0/lib/thin/backends/base.rb:73:in `start' 
2017-05-17T19:04:24.639131+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/thin-1.7.0/lib/thin/server.rb:162:in `start' 
2017-05-17T19:04:24.639132+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/thin-1.7.0/lib/thin/controllers/controller.rb:87:in `start' 
2017-05-17T19:04:24.639133+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/thin-1.7.0/lib/thin/runner.rb:200:in `run_command' 
2017-05-17T19:04:24.639133+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/thin-1.7.0/lib/thin/runner.rb:156:in `run!' 
2017-05-17T19:04:24.639134+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/thin-1.7.0/bin/thin:6:in `<top (required)>' 
2017-05-17T19:04:24.639135+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/bin/thin:22:in `load' 
2017-05-17T19:04:24.639137+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:74:in `load' 
2017-05-17T19:04:24.639136+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/bin/thin:22:in `<top (required)>' 
2017-05-17T19:04:24.639138+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:74:in `kernel_load' 
2017-05-17T19:04:24.639139+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.13.7/lib/bundler/cli.rb:332:in `exec' 
2017-05-17T19:04:24.639140+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run' 
2017-05-17T19:04:24.639138+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:27:in `run' 
2017-05-17T19:04:24.639140+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command' 
2017-05-17T19:04:24.639141+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch' 
2017-05-17T19:04:24.639142+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.13.7/lib/bundler/cli.rb:20:in `dispatch' 
2017-05-17T19:04:24.639143+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start' 
2017-05-17T19:04:24.639144+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.13.7/lib/bundler/cli.rb:11:in `start' 
2017-05-17T19:04:24.639144+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.13.7/exe/bundle:34:in `block in <top (required)>' 
2017-05-17T19:04:24.639145+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.13.7/lib/bundler/friendly_errors.rb:100:in `with_friendly_errors' 
2017-05-17T19:04:24.639146+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.13.7/exe/bundle:26:in `<top (required)>' 
2017-05-17T19:04:24.639146+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/bin/bundle:22:in `load' 
2017-05-17T19:04:24.639147+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/bin/bundle:22:in `<main>' 
2017-05-17T19:04:24.639551+00:00 app[web.1]: 216.73.77.194 - - [17/May/2017:19:04:24 +0000] "POST /sms/send HTTP/1.1" 500 30 0.0217 

Ich bin ein bisschen verloren. Ich entschuldige mich für die Unbestimmtheit. Wo soll ich anfangen?

+0

Ich schlage zuerst vor, Sie sollten Code schreiben, der Ausnahme behandelt. Überprüfen Sie ihr Dokument für die Ausnahmebehandlung. https://www.twilio.com/docs/libraries/ruby#exceptions –

+0

Ich habe das, Kopieren und Einfügen in und Ändern der Telefonnummern. Es wurde der 500 interne Fehler beseitigt, aber nichts sendet. Wenn Sie die Heroku-Protokolle überprüfen, werden keine weiteren Nachrichten angezeigt. – landen

+0

ok. Die lokale Anwendung wird in der Entwicklungsumgebung ausgeführt, und wenn wir sie auf Heroku bereitstellen, wird sie in der Produktionsumgebung ausgeführt. Hast du beide Umgebungseinstellungen für Twilio überprüft? Bitte aktualisieren Sie Ihre Frage und fügen Sie Code zur Ausnahmebehandlung hinzu. –

Antwort

0

Wie in der Diskussion im Kommentar, haben Sie Konfigurationsproblem. Sie können das Programm lokal (Entwicklungsumgebung) und nicht heroku (Produktionsumgebung) ausführen.

Wie Sie im Kommentar erwähnen, verwenden Sie EVN, um Anmeldeinformationen festzulegen. Sie können dies auf zwei Arten einstellen, um ENV in Heroku einzustellen.

1) Schreib Konfiguration in config/production.rb

2) Empfohlen: Set ENV von Heroku Console. Hier ist Ref. link to do it Heroku config vars

Sie können auch Figaro gem für Ihre Anwendung verwenden.

Hoffe, dass hilft!

Verwandte Themen