1

Webapp がユーザーに代わってステータスの更新を投稿できるようにするコードを実行しています。コードはローカルでは問題なく動作していますが、Windows Server 2012 R2 でコードを実行すると、ConnectionException が発生します。

15-Sep-2015 18:40:59.128 SEVERE [http-apr-8080-exec-12] socialmedia.TwitterService.updateTwitterStatus null
 Connection refused: connect
Relevant discussions can be found on the Internet at:
    http://www.google.co.jp/search?q=2fc5b7cb or
    http://www.google.co.jp/search?q=0e20763e
TwitterException{exceptionCode=[2fc5b7cb-0e20763e 2fc5b7cb-0e207614], statusCode=-1, message=null, code=-1, retryAfter=-1, rateLimitStatus=null, version=4.0.3}
    at twitter4j.HttpClientImpl.handleRequest(HttpClientImpl.java:178)
    at twitter4j.HttpClientBase.request(HttpClientBase.java:53)
    at twitter4j.HttpClientBase.post(HttpClientBase.java:82)
    at twitter4j.TwitterImpl.post(TwitterImpl.java:1598)
    at twitter4j.TwitterImpl.updateStatus(TwitterImpl.java:205)
    at de.materna.cmo.socialmedia.TwitterService.updateTwitterStatus(TwitterService.java:37)
    at de.materna.cmo.socialmedia.TwitterService$Proxy$_$$_WeldClientProxy.updateTwitterStatus(Unknown Source)
    at de.materna.cmo.campaignmanagment.CampaignService.deployTwitterContents(CampaignService.java:174)
    at de.materna.cmo.campaignmanagment.CampaignService.deployCampaignContents(CampaignService.java:167)
    at de.materna.cmo.campaignmanagment.CampaignService$Proxy$_$$_WeldClientProxy.deployCampaignContents(Unknown Source)
    at de.materna.cmo.controller.CampaignController.releaseCampaign(CampaignController.java:184)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.el.parser.AstValue.invoke(AstValue.java:247)
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:267)
    at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
    at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
    at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:147)
    at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
    at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:813)
    at javax.faces.component.UICommand.broadcast(UICommand.java:300)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:654)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2503)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2492)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at sun.net.NetworkClient.doConnect(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.http.HttpClient$1.run(Unknown Source)
    at sun.net.www.http.HttpClient$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.http.HttpClient.privilegedOpenServer(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
    at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown Source)
    at twitter4j.HttpClientImpl.handleRequest(HttpClientImpl.java:136)
    ... 50 more

プロパティは次のように構成されます

debug=true
oauth.consumerKey=CONSUMER_KEY
oauth.consumerSecret=CONSUMER_SECRET
oauth.accessToken=ACCESS_TOKEN
oauth.accessTokenSecret=ACCESS_TOKEN_SECRET
http.proxyHost=proxy
http.proxyPort=8080

コード:

@ApplicationScoped
public class TwitterService {
private Twitter twitter;

@Inject
private CmoTask task;

@PostConstruct
public void init() {
    twitter = TwitterFactory.getSingleton();
}

public void updateTwitterStatus(String status) {
    try {
        twitter.updateStatus(status);
    } catch (TwitterException ex) {
        Logger.getLogger(TwitterService.class.getName()).log(Level.SEVERE, null, ex);
    }

}

}

奇妙なことに、私はそれを数時間実行しました。後でローカルで構成を変更したことに関係があるのではないかと思いました.Twitterでは、異なる場所で同じ構成を使用することはできませんでした. 今、私は更新を行いましたが、再び機能しません。別の webapp を登録して、それらのキーを .properties ファイルで使用しようとしました。動作していません。

  • プロキシ設定が正しい
  • サーバーでファイアウォールがオフになっている

私は何が欠けていますか?

前もって感謝します!

4

1 に答える 1

0

サーバーで実際に発生する接続エラーは、サーバーへのアクセスに依存します。https://api.twitter.comに Chrome などの Web ブラウザからアクセスできるかどうかを確認してください。

于 2015-10-12T10:38:20.507 に答える