TwilioDevEd / conversations-quickstart-android

5 stars 6 forks source link

Error creating Twilio Conversations Client #14

Closed headintheclouds21 closed 2 months ago

headintheclouds21 commented 2 months ago

I'm trying to create the ConversationsClient in a java android application and I'm receiving the following error message.

Error 0:3 Command timeout reached

I'm receiving this error while using the same code mentioned on the official Twilio page. I've tried several things with no luck. I have a valid access token. I've reached out to Twilio support and have been redirected here. Can someone please help to resolve this error or advise a solution? Getting this working is crucial for me. I've posted part of the code that's in this Quickstart and is not working. I'm consistently getting an error.


void retrieveAccessTokenFromServer(final Context context, String identity,
                                       final TokenResponseListener listener) {

        // Set the chat token URL in your strings.xml file
        String chatTokenURL = context.getString(R.string.chat_token_url);

        if ("https://YOUR_DOMAIN_HERE.twil.io/chat-token".equals(chatTokenURL)) {
            listener.receivedTokenResponse(false, new Exception("You need to replace the chat token URL in strings.xml"));
            return;
        }

        tokenURL = chatTokenURL + "?identity=" + identity;

        new Thread(new Runnable() {
            @Override
            public void run() {
                retrieveToken(new AccessTokenListener() {
                    @Override
                    public void receivedAccessToken(@Nullable String token,
                                                    @Nullable Exception exception) {
                        if (token != null) {
                            ConversationsClient.Properties props = ConversationsClient.Properties.newBuilder().createProperties();
                            ConversationsClient.create(context, token, props, mConversationsClientCallback);
                            listener.receivedTokenResponse(true,null);
                        } else {
                            listener.receivedTokenResponse(false, exception);
                        }
                    }
                });
            }
        }).start();
}

    private final CallbackListener<ConversationsClient> mConversationsClientCallback =
            new CallbackListener<ConversationsClient>() {
                @Override
                public void onSuccess(ConversationsClient conversationsClient) {
                    QuickstartConversationsManager.this.conversationsClient = conversationsClient;
                    conversationsClient.addListener(QuickstartConversationsManager.this.mConversationsClientListener);
                    Log.d(TAG, "Success creating Twilio Conversations Client");
                }

                @Override
                public void onError(ErrorInfo errorInfo) {
                    errorInfo.getStatus();
                    Log.e(TAG, "Error creating Twilio Conversations Client: " + errorInfo.getMessage());
                }
            };