Giter Site home page Giter Site logo

Comments (10)

nkzawa avatar nkzawa commented on August 16, 2024

Do you want to disconnect a socket manually?
Then call socket.disconnect(); before the lock screen shows up.

from socket.io-client-java.

dashugege avatar dashugege commented on August 16, 2024

no ,I want to don't disconnect the connection,I didn't take the initiative to disconnect, after a minute or so Automatically disconnect? why @nkzawa

from socket.io-client-java.

nkzawa avatar nkzawa commented on August 16, 2024

Ah, I'm not sure, but it sounds like heartbeat between server and client was failed.
Can I see any logs?

from socket.io-client-java.

dashugege avatar dashugege commented on August 16, 2024

The server disconnects the detection arrival,but Disconnect the client is not detected,
socket.on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {

                      @Override
                      public void call(Object... args) {
                          connecting = false ;
                      }
                    });

the callback method not callback ,I want to know why?
Now we don't have to do the heartbeat,
If I was to take the initiative to connect a heartbeat(socket.emit("tag","heartbeat"))?

from socket.io-client-java.

dashugege avatar dashugege commented on August 16, 2024

The lock screen Why is socket automatically disconnect, However .Don't lock screen socket Don't disconnect ?I hope to get your help

from socket.io-client-java.

sergio91pt avatar sergio91pt commented on August 16, 2024

You need to use a partial WakeLock 1 and if the connection is through
wifi, you should also acquire a WifiLock 2.

2014-09-25 10:08 GMT+01:00 dashugege [email protected]:

The lock screen Why is socket automatically disconnect, However .Don't
lock screen socket Don't disconnect ?I hope to get your help


Reply to this email directly or view it on GitHub
#44 (comment)
.

from socket.io-client-java.

dashugege avatar dashugege commented on August 16, 2024

I come from China,Part of the cell phone lock screen broken links,Part of the phone lock screen no broken links,I checked the source code,
this.pingTimeoutTimer = this.getHeartbeatScheduler().schedule(new Runnable() {
@OverRide
public void run() {
EventThread.exec(new Runnable() {
@OverRide
public void run() {
if (self.readyState == ReadyState.CLOSED) return;
self.onClose("ping timeout");//this code bug
}
});
}
}, timeout, TimeUnit.MILLISECONDS);
You met this problem

from socket.io-client-java.

mifoss avatar mifoss commented on August 16, 2024

i have the same problem, i have a service running in background, but the connection is lost without any event....

here is a part of my code:

 @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        WakeLock wakelock = ((PowerManager)getSystemService(POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Chat Service");
        wakelock.acquire();
        Log.i(Globals.DEBUG_TAG, "PushService start command");
        if(intent != null) Log.i(Globals.DEBUG_TAG, intent.toUri(0));
        mShutDown = false;
        if(mClient == null) {
            WakeLock clientlock = ((PowerManager)getSystemService(POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Chat");

            TokenManager tokenManager = new TokenManager(getApplicationContext());

            mClient = ConnectionManager.getInstance(tokenManager);
        }

        if(!isConnected()) {
            connected = true;
                mClient.connect();

                if (!mClient.hasListeners("message")) {
                    Log.d(Globals.DEBUG_TAG, "no listeners");
                    mClient.on("message", onMessage);
                    mClient.on(Socket.EVENT_CONNECT, onConnect);
                    mClient.on(Socket.EVENT_DISCONNECT, onDisconnect);
                    mClient.on(Socket.EVENT_CONNECT_ERROR, onError);
                    mClient.on(Socket.EVENT_ERROR, onError);
                    mClient.on(Socket.EVENT_RECONNECT, onReconnect);
                }
            }


        if(intent != null) {
            if(ACTION_PING.equals(intent.getAction())){
                 Log.d(Globals.DEBUG_TAG, "PING EVENT");
                JSONObject ping = new JSONObject();
                try {
                    ping.put("ping", "ping");
                } catch (JSONException e) {
                    e.printStackTrace();
                }

                mClient.emit("ping", ping, new Ack() {
                    @Override
                    public void call(Object... args) {
                        Log.d(Globals.DEBUG_TAG, "recieved ping callback");
                    }
                });

            } else if(ACTION_SHUT_DOWN.equals(intent.getAction())){
                mShutDown = true;
                if(mClient.connected()) {
                    mClient.disconnect();
                }
            }
        }

        if(intent == null || !intent.getAction().equals(ACTION_SHUT_DOWN)){
            AlarmManager am = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
            PendingIntent operation = PendingIntent.getService(this, 0, ConnectionService.pingIntent(this), PendingIntent.FLAG_NO_CREATE);
            if(operation == null){
                operation = PendingIntent.getService(this, 0, ConnectionService.pingIntent(this), PendingIntent.FLAG_UPDATE_CURRENT);
                am.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), AlarmManager.INTERVAL_FIFTEEN_MINUTES, operation);
            }
        }

        wakelock.release();
        return START_STICKY;
    }

if i lock the screen then i can see "PING EVENT" in my Logcat view but my server does not recieve the message "ping"

thanks for this great library

anrpi

from socket.io-client-java.

darrachequesne avatar darrachequesne commented on August 16, 2024

Closed due to inactivity, please reopen if needed.

from socket.io-client-java.

gaochuntie avatar gaochuntie commented on August 16, 2024

I also have this problem

from socket.io-client-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.