Исключение сокета: сброс соединения для twilio API - PullRequest
0 голосов
/ 21 января 2019

Я пытался реализовать whatapp messeging через twilio API. Исключение при получении:

Исключение в потоке "main" com.twilio.exception.ApiException: сброс соединения

Я имел в виду this для примера реализации кода

public static void main( String[] args )
{

    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
    Message message = Message.creator(
            new com.twilio.type.PhoneNumber("whatsapp:+91xxxxxxxxxx"),
            new com.twilio.type.PhoneNumber("whatsapp:+91xxxxxxxxxx"),
            "Hello there!")
        .create();

    System.out.println(message.getSid());}
}

Получение исключения:

Exception in thread "main" com.twilio.exception.ApiException: Connection reset
    at com.twilio.http.NetworkHttpClient.makeRequest(NetworkHttpClient.java:128)
    at com.twilio.http.HttpClient.reliableRequest(HttpClient.java:42)
    at com.twilio.http.HttpClient.reliableRequest(HttpClient.java:25)
    at com.twilio.http.TwilioRestClient.request(TwilioRestClient.java:42)
    at com.twilio.rest.api.v2010.account.MessageCreator.create(MessageCreator.java:491)
    at com.twilio.rest.api.v2010.account.MessageCreator.create(MessageCreator.java:25)
    at com.twilio.base.Creator.create(Creator.java:45)
    at test.whatsaap.App.main(App.java:26)
Caused by: java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:209)
    at java.net.SocketInputStream.read(SocketInputStream.java:141)
    at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
    at sun.security.ssl.InputRecord.read(InputRecord.java:503)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:396)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:355)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:394)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
    at com.twilio.http.NetworkHttpClient.makeRequest(NetworkHttpClient.java:120)
    ... 7 more
...