I'm creating authorization app, where I'm using Retrofit 2. When I'm doing call, that goes to onFailure method and gets exception
"javax.net.ssl.SSLException: Connection closed by peer"
But the problem is, that yesterday this worked great. Today it gives exception. I find in internet some SSLException - Connection closed by peer on Android 4.x versions, or this How to add TLS v 1.0 and TLS v.1.1 with Retrofit, but this not helped me. Any ideas how to fix it. In backend TLS1.2 is enable.
public class RegistrationFragment extends BaseFragment {
View mainView;
ApiClient apiClient = ApiClient.getInstance();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mainView = inflater.inflate
(R.layout.registration_fragment, container, false);
//Calling the authorization method
registerCall();
}
});
return mainView;
}
//User authorization method
public void registerCall() {
Call<ResponseBody> call = apiClient.registration(supportopObj);
call.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
if (response.isSuccessful()) {
//Calling the clientCall method for getting the user clientID and clientSecret
Toast.makeText(getActivity(), "Registration Successful ",
Toast.LENGTH_SHORT).show();;
} else {
//if the response not successful
Toast.makeText(getActivity(), "Could not register the user maybe already registered ",
Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
Toast.makeText(getActivity(), "An error occurred", Toast.LENGTH_SHORT).show();
}
});
}
}