follow post #4 from
https://www.b4x.com/android/forum/threads/okhttp-cancel-download.61239/
you'll have to do a little work to make it fit your scenario.
also, the failure to time out with ok is apparently not unknown.
ok provides 4 time out settings:
OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(5, TimeUnit.SECONDS)
.writeTimeout(5, TimeUnit.SECONDS)
.readTimeout(5, TimeUnit.SECONDS)
.callTimeout(30, TimeUnit.SECONDS)
.build();
our okhttp.jar sets 3 of them. i've played around with setting them variously. anyway, the issue - when it occurs - is said to ignore all 4. you can follow the online discussion starting at google. at my last read, i didn't see a definitive resolution. or even a definitive explanation as to why it occurs at all.
ok also has an automatic retry feature which can be turned off (should that feature be involved). people who have experienced the failure to time out have turned the automatic retry off, the the hanging was not solved...
cancelling the socket connection with a modified okhttputils2 (per post above) and a timer would seem to be a way out.