2014-11-21 59 views
0

我有部署在Heroku上的Play 2.2應用程序。當我只有1個測功機時它工作得很好。如果我添加至少一個動態碼,則會出現非常煩人的問題:隨機,不定時與Twitter或Facebook登錄失敗。Heroku上的SecureSocial登錄問題使用#個dynos> 1

我檢查了日誌,它看起來像問題是來自Twitter的請求。

2014-11-21T16:46:54.880238+00:00 heroku[router]: at=info method=GET path="/authenticate/twitter" host=teller.happymelly.com request_id=2c9e9ce7-8055-491d-841a-919a560461ef fwd="95.28.27.42" dyno=web.1 connect=1ms service=299ms status=303 bytes=398 
2014-11-21T16:46:56.245743+00:00 heroku[router]: at=info method=GET path="/authenticate/twitter?oauth_token=XXXX&oauth_verifier=XXXX" host=teller.happymelly.com request_id=fc7966a3-082f-418b-a424-ff4868cbf175 fwd="95.28.27.42" dyno=web.1 connect=1ms service=20ms status=301 bytes=227 
2014-11-21T16:46:56.404711+00:00 heroku[router]: at=info method=GET path="/authenticate/twitter?oauth_token=XXXX&oauth_verifier=XXXX" host=teller.happymelly.com request_id=50f15633-fd9d-431b-a132-403821767495 fwd="95.28.27.42" dyno=web.2 connect=1ms service=9ms status=303 bytes=190 
2014-11-21T16:46:56.400002+00:00 app[web.2]: [error] application - Unable to log user in. An exception was thrown 
2014-11-21T16:46:56.400007+00:00 app[web.2]: securesocial.core.AuthenticationException: null 
2014-11-21T16:46:56.400010+00:00 app[web.2]: at securesocial.core.OAuth1Provider$$anonfun$doAuth$1$$anonfun$apply$8.apply(OAuth1Provider.scala:84) ~[ws.securesocial.securesocial_2.10-2.1.3.jar:2.1.3] 
2014-11-21T16:46:56.400012+00:00 app[web.2]: at securesocial.core.OAuth1Provider$$anonfun$doAuth$1$$anonfun$apply$8.apply(OAuth1Provider.scala:84) ~[ws.securesocial.securesocial_2.10-2.1.3.jar:2.1.3] 
2014-11-21T16:46:56.400014+00:00 app[web.2]: at scala.Option.getOrElse(Option.scala:120) [org.scala-lang.scala-library-2.10.3.jar:na] 
2014-11-21T16:46:56.400016+00:00 app[web.2]: at securesocial.core.OAuth1Provider$$anonfun$doAuth$1.apply(OAuth1Provider.scala:84) ~[ws.securesocial.securesocial_2.10-2.1.3.jar:2.1.3] 
2014-11-21T16:46:56.400018+00:00 app[web.2]: at securesocial.core.OAuth1Provider$$anonfun$doAuth$1.apply(OAuth1Provider.scala:62) ~[ws.securesocial.securesocial_2.10-2.1.3.jar:2.1.3] 
2014-11-21T16:46:56.400020+00:00 app[web.2]: at scala.Option.map(Option.scala:145) [org.scala-lang.scala-library-2.10.3.jar:na] 

該模式是穩定的。只要有來自Twitter的一個請求,一切正常。

2014-11-21T16:48:41.633181+00:00 heroku[router]: at=info method=GET path="/authenticate/twitter" host=teller.happymelly.com request_id=d3bdb519-8b4e-450e-a650-3ea5a840b90f fwd="95.28.27.42" dyno=web.2 connect=1ms service=679ms status=303 bytes=398 
2014-11-21T16:48:42.629072+00:00 heroku[router]: at=info method=GET path="/authenticate/twitter?oauth_token=XXX&oauth_verifier=XXX" host=teller.happymelly.com request_id=740ac75a-1d37-4587-9628-50e703d7ad31 fwd="95.28.27.42" dyno=web.1 connect=1ms service=6ms status=301 bytes=227 
2014-11-21T16:48:43.315185+00:00 app[web.2]: [debug] application - GET https://api.twitter.com/1.1/account/settings.json 
2014-11-21T16:48:43.351654+00:00 app[web.2]: [debug] application - 200 OK 

有沒有人遇到過這樣的問題?任何建議我應該挖掘什麼方向?

這非常煩人,因爲有時訪客必須點擊「登錄」按鈕3-4次。任何幫助非常感謝。

+0

無碼沒有人能夠幫助你。 – Ryan 2014-11-21 20:55:44

+0

您是否爲應用程序設置了分佈式緩存實例?社交提供者緩存一些認證工件。所以你應該在集羣環境中使用分佈式緩存。 – akkie 2014-11-22 06:26:31

+0

@akkie我建立了一個分佈式緩存,但只適用於Secure Social(通過它的插件)。正如Julien在下面提到的,我可能需要爲整個應用程序設置分佈式緩存。 – sery0ga 2014-11-22 14:29:50

回答

1

要在Heroku上使用安全的社會:

  • 使用Memcachier附加到DYNOS之間共享緩存。 事實上,OAuth發出了幾個請求(爲了獲得授權碼,然後是令牌),並且在請求之間Heroku將臨時信息存儲在緩存中。當請求來自不同的dynos時,它們沒有所有的信息,所以它失敗了。

  • Memcachier有SecureSocial一個小問題,解決這裏http://marcinkubala.wordpress.com/2013/11/26/securescial-memcached-never-that-easy/

+0

謝謝,我會試試這個。我使用分佈式緩存,但僅限於Secure Social。可能是問題出在那裏。 – sery0ga 2014-11-22 14:28:32