I'm posting the exact same title as this post Faraday timeout error with omniauth (custom strategy)/doorkeeper because I'm just having the same, and almost exact problem. I tested the same code in centOS (I'm currently on windows) and it worked alright. I'm currently using puma, and as the answer for the other post says, I'm running it with this command: rails s Puma THREADS=1
Started GET "/api/v1/explore?code=3135f40914f480b6cf9a05145dcc76d6db17826bf07644f4531b1051cb032188" for 127.0.0.1 at 2014-07-17 18:30:15 -0430
Processing by Api::V1::CredentialsController#explore as JSON
Parameters: {"code"=>"3135f40914f480b6cf9a05145dcc76d6db17826bf07644f4531b1051cb032188"}
Completed 500 Internal Server Error in 61003ms
Faraday::TimeoutError (Net::ReadTimeout):
app/controllers/api/v1/credentials_controller.rb:14:in `explore'
Rendered C:/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.5ms)
Rendered C:/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.0ms)
Rendered C:/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.5ms)
Rendered C:/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (34.5ms)
Started POST "/oauth/token" for 127.0.0.1 at 2014-07-17 18:31:17 -0430
Processing by Doorkeeper::TokensController#create as */*
Parameters: {"client_id"=>"46e33715e9cbc0189341f02547232c91bbf892e12a16e33b1f93307b56004489",
"client_secret"=>"b227791b33b29f567a03dda66af0d826dad57c03390b52129034f497e29d6a31", "code"=>"3135f40914f480b6cf9a05145dcc76d6db17826bf07644f4531b1051cb032188", "grant_type"=>"authorization_code", "redirect_uri"=>"http://localhost:3001/api/v1/me"}
Doorkeeper::AccessGrant Load (0.5ms) SELECT `oauth_access_grants`.* FROM `oauth_access_grants` WHERE `oauth_access_grants`.`token` = '3135f40914f480b6cf9a05145dcc76d6db17826bf07644f4531b1051cb032188' ORDER BY `oauth_access_grants`.`id` ASC LIMIT 1
Doorkeeper::Application Load (0.5ms) SELECT `oauth_applications`.* FROM `oauth_applications`
WHERE `oauth_applications`.`uid` = '46e33715e9cbc0189341f02547232c91bbf892e12a16e33b1f93307b56004489' AND `oauth_applications`.`secret` = 'b227791b33b29f567a03dda66af0d826dad57c03390b52129034f497e29d6a31' ORDER BY `oauth_applications`.`id` ASC LIMIT 1
SQL (31.0ms) UPDATE `oauth_access_grants` SET `oauth_access_grants`.`revoked_at` = '2014-07-17 23:01:17' WHERE `oauth_access_grants`.`id` = 45
Doorkeeper::Application Load (2.5ms) SELECT `oauth_applications`.* FROM `oauth_applications`
WHERE `oauth_applications`.`id` = 2 ORDER BY `oauth_applications`.`id` ASC LIMIT 1
(0.5ms) BEGIN
Doorkeeper::AccessToken Exists (0.5ms) SELECT 1 AS one FROM `oauth_access_tokens` WHERE `oauth_access_tokens`.`token` = BINARY '26c85c68472f60790993f9b277da3db3a255933966e3a995dfb069c04fa4ffd6' LIMIT 1
SQL (1.0ms) INSERT INTO `oauth_access_tokens` (`application_id`, `created_at`, `expires_in`,
`resource_owner_id`, `scopes`, `token`) VALUES (2, '2014-07-17 23:01:17', 7200, 1, '', '26c85c68472f60790993f9b277da3db3a255933966e3a995dfb069c04fa4ffd6')
(1.0ms) COMMIT
Completed 200 OK in 113ms (ActiveRecord: 40.0ms)
So as you might see, it creates the access token and all, but it returns an internal server error 500
and here is the full stack trace:
C:/Ruby200/lib/ruby/2.0.0/net/protocol.rb:158:in `rescue in rbuf_fill'
C:/Ruby200/lib/ruby/2.0.0/net/protocol.rb:152:in `rbuf_fill'
C:/Ruby200/lib/ruby/2.0.0/net/protocol.rb:134:in `readuntil'
C:/Ruby200/lib/ruby/2.0.0/net/protocol.rb:144:in `readline'
C:/Ruby200/lib/ruby/2.0.0/net/http/response.rb:39:in `read_status_line'
C:/Ruby200/lib/ruby/2.0.0/net/http/response.rb:28:in `read_new'
C:/Ruby200/lib/ruby/2.0.0/net/http.rb:1406:in `block in transport_request'
C:/Ruby200/lib/ruby/2.0.0/net/http.rb:1403:in `catch'
C:/Ruby200/lib/ruby/2.0.0/net/http.rb:1403:in `transport_request'
C:/Ruby200/lib/ruby/2.0.0/net/http.rb:1376:in `request'
C:/Ruby200/lib/ruby/2.0.0/net/http.rb:1369:in `block in request'
C:/Ruby200/lib/ruby/2.0.0/net/http.rb:852:in `start'
C:/Ruby200/lib/ruby/2.0.0/net/http.rb:1367:in `request'
faraday (0.9.0) lib/faraday/adapter/net_http.rb:80:in `perform_request'
faraday (0.9.0) lib/faraday/adapter/net_http.rb:39:in `call'
faraday (0.9.0) lib/faraday/request/url_encoded.rb:15:in `call'
faraday (0.9.0) lib/faraday/rack_builder.rb:139:in `build_response'
faraday (0.9.0) lib/faraday/connection.rb:377:in `run_request'
oauth2 (1.0.0) lib/oauth2/client.rb:93:in `request'
oauth2 (1.0.0) lib/oauth2/client.rb:138:in `get_token'
oauth2 (1.0.0) lib/oauth2/strategy/auth_code.rb:29:in `get_token'
actionpack (4.0.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.0.0) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.0.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.0.0) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (4.0.0) lib/active_support/callbacks.rb:393:in `_run__607914739__process_action__callbacks'
activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.0) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (4.0.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.0.0) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.0.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.0.0) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.0.0) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (4.0.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.0.0) lib/abstract_controller/base.rb:136:in `process'
actionpack (4.0.0) lib/abstract_controller/rendering.rb:44:in `process'
actionpack (4.0.0) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.0.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.0.0) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:80:in `call'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:655:in `call'
omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/flash.rb:241:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/cookies.rb:486:in `call'
activerecord (4.0.0) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
activerecord (4.0.0) lib/active_record/migration.rb:369:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.0.0) lib/active_support/callbacks.rb:373:in `_run__662709576__call__callbacks'
activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/reloader.rb:64:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `block in call'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `block in tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:in `call'
railties (4.0.0) lib/rails/engine.rb:511:in `call'
railties (4.0.0) lib/rails/application.rb:97:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
puma (2.9.0) lib/puma/server.rb:490:in `handle_request'
puma (2.9.0) lib/puma/server.rb:361:in `process_client'
puma (2.9.0) lib/puma/server.rb:254:in `block in run'
puma (2.9.0) lib/puma/thread_pool.rb:92:in `call'
puma (2.9.0) lib/puma/thread_pool.rb:92:in `block in spawn_thread'
and here is the explore action which is supposed to create the access token, but it gets stuck until the timeout error
def explore
client = OAuth2::Client.new(DOORKEEPER_APP_ID, DOORKEEPER_APP_SECRET, :site => "http://localhost:3001")
token = client.auth_code.get_token(params[:code], redirect_uri: "http://localhost:3001/api/v1/me")
respond_with token
end
I already followed the omniauth strategy tutorial on github and the doorkeeper provider tutorial as well. As I said before, it works well and creates an access token in centOS, but in windows I get this error, I even went through this tutorial with no results https://gist.github.com/fnichol/867550 and also tried out different faraday adapters, with almost the same result.
PD: Thank you very much for helping, and sorry about my english