java - How are timeouts set for AndroidAsync websockets? -


i trying change default androidasync websocket initial connection timeout of 30 seconds. working version default timeout:

asynchttpclient.getdefaultinstance().websocket(connectionuri.tostring(), null, this); 

i change timeout. expected work:

int timeout_ms = 20000; asynchttpget request = new asynchttpget(connectionuri.tostring()); request.settimeout(timeout_ms); asynchttpclient.getdefaultinstance().websocket(request, null, this); 

this results in java.lang.illegalargumentexception: invalid uri=ws://exampleserver.com:80/test middlewares=[com.koushikdutta.async.http.httptransportmiddleware@1e2543c8, com.koushikdutta.async.http.spdy.spdymiddleware@2534fc61, com.koushikdutta.async.http.asyncsocketmiddleware@107b3386]

note same connectionuri string successful in first case, not second.

is there way change timeout of androidasync websocket?

this hack helped me.you need pass http or htpps protocol.

    asynchttpget request = new asynchttpget("ws://xxx.xxx.x.xx:8500".replace("ws://", "http://").replace("wss://", "https://"));     request.settimeout(3000);      asynchttpclient asynchttpclient = asynchttpclient.getdefaultinstance();     asynchttpclient.websocket(request, null, websocketconnectcallback); 

Popular posts from this blog