Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error pinging server #24

Closed
anilustel opened this issue Oct 18, 2015 · 7 comments
Closed

Error pinging server #24

anilustel opened this issue Oct 18, 2015 · 7 comments
Assignees
Labels

Comments

@anilustel
Copy link

Hi, i am getting the following ex;

10-18 15:41:08.993  22772-22772/com.android.** I/ProxyCache﹕ Proxy cache server started. Ping it...
10-18 15:41:08.997  22772-22900/com.android.** D/ProxyCache﹕ Open connection  to http://127.0.0.1:55999/ping
10-18 15:41:09.198  22772-22772/com.android.** E/ProxyCache﹕ Error pinging server [attempt: 0, timeout: 200].
    java.util.concurrent.TimeoutException
            at java.util.concurrent.FutureTask.get(FutureTask.java:176)
            at com.danikula.videocache.HttpProxyCacheServer.makeSureServerWorks(HttpProxyCacheServer.java:87)
            at com.danikula.videocache.HttpProxyCacheServer.<init>(HttpProxyCacheServer.java:73)
            at com.android.**.code.AApplication.newProxy(AApplication.java:45)
            at com.android.**.code.AApplication.getProxy(AApplication.java:40)
            at com.android.**.code.activity.Splash.getNextAd(Splash.java:118)
            at com.android.**.code.activity.Splash.access$000(Splash.java:44)
            at com.android.**.code.activity.Splash$1.onSuccess(Splash.java:91)
            at com.android.**.code.activity.Splash$1.onSuccess(Splash.java:83)
            at com.android.**.code.retrofit.RetrofitCallback.success(RetrofitCallback.java:87)
            at retrofit.CallbackRunnable$1.run(CallbackRunnable.java:45)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

What does it mean? how can i solve this problem? Thank yoouuu.

@pinhassi
Copy link

There is a small bug in HttpProxyCacheServer.makeSureServerWorks() -
On TimeoutException, pingAttempts doesn't update so the error repeat itself endlessly, preventing from the server to start.

Solution:
Update delay & pingAttempts out side the try->catch section.

private void makeSureServerWorks() {
    int maxPingAttempts = 5;
    int delay = 200;
    int pingAttempts = 0;
    while (pingAttempts < maxPingAttempts) {
        try {
            Future<Boolean> pingFuture = socketProcessor.submit(new PingCallable());
            pinged = pingFuture.get(delay, TimeUnit.MILLISECONDS);
            if (pinged) {
                return;
            }
            SystemClock.sleep(delay);
        } catch (InterruptedException | ExecutionException | TimeoutException e) {
            Log.e(LOG_TAG, "Error pinging server [attempt: " + pingAttempts + ", timeout: " + delay + "]. ", e);
        }
        delay *= 2;
        pingAttempts++;
    }

    Log.e(LOG_TAG, "Shutdown server… Error pinging server [attempt: " + pingAttempts + ", timeout: " + delay + "]. " +
            "If you see this message, please, email me [email protected]");
    shutdown();
}

@danikula
Copy link
Owner

@pinhassi You are absolutely right! Can you make pull request?

@danikula danikula changed the title timeout Error pinging server Oct 20, 2015
@anilustel
Copy link
Author

Thx for your response,

I am using gradle version.
Will you update gradle version or want me to fix your code in my project?

Thx.

@danikula
Copy link
Owner

@anilustel Which version of gradle and gradle plugin do you use?

@danikula danikula added the bug label Oct 22, 2015
@danikula danikula self-assigned this Oct 22, 2015
danikula added a commit that referenced this issue Oct 28, 2015
@danikula
Copy link
Owner

@pinhassi Thanks for your bug report. I fixed it in 2.3.2 version.

@danikula
Copy link
Owner

@anilustel After proxy starts it check whether it works fine. It does few ping request to itself. In your log I see single first attempt (Error pinging server [attempt: 0, timeout: 200]). But it should make 3 attempts. Try to update to the latest 2.3.2 version. If proxy will not work please let me know and provide full log.

@danikula
Copy link
Owner

Let's discuss this problem here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants