0

画像ファイルを aws バケットにアップロードしようとしていますが、デバイスでこのエラーに何度か直面しています。

I/AmazonHttpClient: Unable to execute HTTP request: Unable to resolve host "cognito-identity.us-east-1.amazonaws.com": No address associated with hostname
                                                                  java.net.UnknownHostException: Unable to resolve host "cognito-identity.us-east-1.amazonaws.com": No address associated with hostname
                                                                      at java.net.InetAddress.lookupHostByName(InetAddress.java:400)
                                                                      at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
                                                                      at java.net.InetAddress.getAllByName(InetAddress.java:220)
                                                                      at libcore.net.http.HttpConnection.<init>(HttpConnection.java:71)
                                                                      at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
                                                                      at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)
                                                                      at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
                                                                      at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
                                                                      at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
                                                                      at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:460)
                                                                      at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:441)
                                                                      at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
                                                                      at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
                                                                      at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
                                                                      at libcore.net.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:188)
                                                                      at libcore.net.http.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:280)
                                                                      at com.amazonaws.http.UrlHttpClient.writeContentToConnection(UrlHttpClient.java:128)
                                                                      at com.amazonaws.http.UrlHttpClient.execute(UrlHttpClient.java:65)
                                                                      at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:353)
                                                                      at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:196)
                                                                      at com.amazonaws.services.cognitoidentity.AmazonCognitoIdentityClient.invoke(AmazonCognitoIdentityClient.java:533)
                                                                      at com.amazonaws.services.cognitoidentity.AmazonCognitoIdentityClient.getId(AmazonCognitoIdentityClient.java:344)
                                                                      at com.amazonaws.auth.AWSAbstractCognitoIdentityProvider.getIdentityId(AWSAbstractCognitoIdentityProvider.java:170)
                                                                      at com.amazonaws.auth.AWSEnhancedCognitoIdentityProvider.refresh(AWSEnhancedCognitoIdentityProvider.java:76)
                                                                      at com.amazonaws.auth.CognitoCredentialsProvider.startSession(CognitoCredentialsProvider.java:537)
                                                                      at com.amazonaws.auth.CognitoCredentialsProvider.getCredentials(CognitoCredentialsProvider.java:370)
                                                                      at com.amazonaws.auth.CognitoCachingCredentialsProvider.getCredentials(CognitoCachingCredentialsProvider.java:440)
                                                                      at com.amazonaws.auth.CognitoCachingCredentialsProvider.getCredentials(CognitoCachingCredentialsProvider.java:76)
                                                                      at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4198)
                                                                      at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1618)
                                                                      at com.amazonaws.mobileconnectors.s3.transferutility.UploadTask.uploadSinglePartAndWaitForCompletion(UploadTask.java:174)
                                                                      at com.amazonaws.mobileconnectors.s3.transferutility.UploadTask.call(UploadTask.java:74)
                                                                      at com.amazonaws.mobileconnectors.s3.transferutility.UploadTask.call(UploadTask.java:40)
                                                                      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
                                                                      at java.util.concurrent.FutureTask.run(FutureTask.java:137)
                                                                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
                                                                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
                                                                      at java.lang.Thread.run(Thread.java:856)

しかし、しばらくすると、次のように表示されます。

D/CognitoCachingCredentialsProvider: Identity id is changed
12-12 11:27:25.771 11239-14564/D/CognitoCachingCredentialsProvider: Saving identity id to SharedPreferences
12-12 11:27:25.771 11239-11246/com.amlooking4 I/dalvikvm: Jit: resizing JitTable from 4096 to 8192
12-12 11:27:26.161 11239-14564/D/CognitoCachingCredentialsProvider: Saving credentials to SharedPreferences

編集済み:

今、私もこれを手に入れています、

    I/AmazonHttpClient: Unable to execute HTTP request: SSL handshake timed out
                                                                      java.net.SocketTimeoutException: SSL handshake timed out

 Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x1e5dff8: Failure in SSL library, usually a protocol error
                                                                  error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:658 0x401d6cf5:0x00000000)
                                                                      at org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_do_handshake(Native Method)
                                                                      at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:410)
                                                                        ... 23 more

この不正行為のために本当にイライラしています。コードは同じですが、完全に実行される場合もあれば、そうでない場合もあり、上記のエラーが表示されます。

私はawsを初めて使用します。cognito idが設定に保存されることを理解しています。

4

1 に答える 1

2

このコードを Utils.Java に追加します

    private static CognitoCachingCredentialsProvider getCredProvider(Context context) {
    if (sCredProvider == null) {
        ClientConfiguration clientConfiguration = new ClientConfiguration();
        clientConfiguration.setConnectionTimeout(30000);
        clientConfiguration.setSocketTimeout(30000);
        sCredProvider = new CognitoCachingCredentialsProvider(
                context.getApplicationContext(),
                Constants.COGNITO_POOL_ID,
                Regions.fromName(Constants.COGNITO_POOL_REGION),clientConfiguration);
    }
    return sCredProvider;
};    

amazonS3Client は次のようになります。

     public static AmazonS3Client getS3Client(Context context) {
    if (sS3Client == null) {
        sS3Client = new AmazonS3Client(getCredProvider(context.getApplicationContext()));
        sS3Client.setRegion(Region.getRegion(Regions.fromName(Constants.BUCKET_REGION)));

    }
    return sS3Client;
};
于 2017-05-09T06:58:04.553 に答える