Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Real Time Multiplayer - Room Creation is failing

I am using Android Play Games - Real Time Multiplayer for my app. When I create a new room, the callback onRoomCreated() returns STATUS_NETWORK_ERROR_NO_DATA 5% of the times. I do not know why I get this error sporadic.

Some post recommends should be closed before creating a new one. I always leave my rooms before super.onstop() is called. I also wait for the callback onLeftRoom() before creating a new room.

StackTrace

02-20 22:57:07.208: I/libjingle(1763): Token type:OAuth2
02-20 22:57:07.208: I/libjingle(1763): Final XMPP server hostname talk.google.com port to 5222
02-20 22:57:07.316: I/libjingle(1763): OpenSSLAdapter::OnConnectEvent
02-20 22:57:07.416: I/libjingle(1763): BeginSSL: talk.google.com
02-20 22:57:07.476: W/libjingle(1763): Warning(openssladapter.cc:388): ContinueSSL -- error -1
02-20 22:57:07.480: W/libjingle(1763): Warning(openssladapter.cc:397): OpenSSLAdapter::Error(ContinueSSL, -1)
02-20 22:57:07.504: I/libjingle(1763): SSL Cleanup
02-20 22:57:07.532: I/libjingle(1763): Token type:OAuth2
02-20 22:57:07.532: I/libjingle(1763): Final XMPP server hostname talk.google.com port to 5222
02-20 22:57:07.596: I/libjingle(1763): OpenSSLAdapter::OnConnectEvent
02-20 22:57:07.692: I/libjingle(1763): BeginSSL: talk.google.com
02-20 22:57:07.752: W/libjingle(1763): Warning(openssladapter.cc:388): ContinueSSL -- error -1
02-20 22:57:07.752: W/libjingle(1763): Warning(openssladapter.cc:397): OpenSSLAdapter::Error(ContinueSSL, -1)
02-20 22:57:07.764: D/MMC(5796): error onRoomCreated status: STATUS_NETWORK_ERROR_NO_DATA
02-20 22:57:07.796: I/libjingle(1763): SSL Cleanup
02-20 22:57:07.812: D/ChimeraCfgMgr(721): Loading module com.google.android.gms.games from APK com.google.android.play.games
02-20 22:57:07.812: D/ChimeraModuleLdr(721): Module APK com.google.android.play.games already loaded
02-20 22:57:08.520: D/dalvikvm(5796): GC_CONCURRENT freed 1059K, 23% free 8651K/11143K, paused 16ms+1ms, total 42ms
02-20 22:57:12.948: D/dalvikvm(485): GC_CONCURRENT freed 384K, 23% free 5746K/7367K, paused 7ms+1ms, total 18ms
02-20 22:57:24.932: I/Ads(5796): Ad is not visible. Not refreshing ad.
02-20 22:57:24.932: I/Ads(5796): Scheduling ad refresh 60000 milliseconds from now.
02-20 22:57:53.660: D/dalvikvm(5796): GC_CONCURRENT freed 1257K, 25% free 8434K/11143K, paused 22ms+1ms, total 38ms
02-20 22:57:57.044: I/ClearcutLoggerApiImpl(532): disconnect managed GoogleApiClient
02-20 22:57:58.960: I/GLSUser(5709): GLS error: BadAuthentication 123456789 oauth2:https://www.googleapis.com/auth/games
02-20 22:57:58.960: V/GoogleLoginService(5709): Returning error intent with: ComponentInfo{com.google.android.gsf.login/com.google.android.gsf.login.LoginActivity}
02-20 22:57:59.008: W/PlayEventLogger(721): deferring log upload because couldn't retrieve auth token

Does anyone know why I get this error? I am thankful for each hint.

Edit:

I am starting a new game activity from a main menu activity. When the game is over, I am closing the room and then i return to the main menu activity.

Here is an excerpt of the game activity:

private GoogleApiClient mGoogleApiClient;
private String mRoomId;
private final static int RC_WAITING_ROOM = 10002;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_multiplayer);
    // Create the Google Api Client with access to Plus and Games
    mGoogleApiClient = new GoogleApiClient.Builder(this)
        .addConnectionCallbacks(this)
        .addOnConnectionFailedListener(this)
        .addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN)
        .addApi(Games.API).addScope(Games.SCOPE_GAMES)
        .build();
}

private void startQuickGame() {
    Log.d("MMC", "debug startgame()");
    // auto-match criteria to invite one random automatch opponent.
    // You can also specify more opponents (up to 3).
    Bundle am = RoomConfig.createAutoMatchCriteria(2, 6, 0);

    // build the room config:
    RoomConfig.Builder roomConfigBuilder = makeBasicRoomConfigBuilder();
    roomConfigBuilder.setAutoMatchCriteria(am);
    RoomConfig roomConfig = roomConfigBuilder.build();

    // create room:
    Games.RealTimeMultiplayer.create(mGoogleApiClient, roomConfig);

    // prevent screen from sleeping during handshake
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    // go to game screen
}

// create a RoomConfigBuilder that's appropriate for your implementation
private RoomConfig.Builder makeBasicRoomConfigBuilder() {
    Log.d("MMC", "debug makeBasicRoomConfigBuilder()");
    return RoomConfig.builder(this)
        .setMessageReceivedListener(this)
        .setRoomStatusUpdateListener(this);
}


@Override
public void onRoomCreated(int statusCode, Room room) {
    Log.d("MMC", "debug onRoomCreated status:" + statusCode);
    if (statusCode != GamesStatusCodes.STATUS_OK) {
        // let screen go to sleep
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        return;
        // show error message, return to main screen.
    }
    mRoomId = room.getRoomId();
    // get waiting room intent
    Intent i = Games.RealTimeMultiplayer.getWaitingRoomIntent(mGoogleApiClient, room, Integer.MAX_VALUE);
    startActivityForResult(i, RC_WAITING_ROOM);
}

@Override
public void onRoomConnected(int statusCode, Room room) {
    Log.d("MMC", "debug onRoomConnected status:" + statusCode);
    if (statusCode != GamesStatusCodes.STATUS_OK) {
        Log.d("MMC", "debug onRoomConnected error");
        // let screen go to sleep
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        // show error message, return to main screen.
    }
}

boolean mPlaying = false;

// at least 2 players required for our game
final static int MIN_PLAYERS = 2;

@Override
public void onActivityResult(int request, int response, Intent intent) {
    Log.d("MMC", "debug onActivityResult()");
    if (request == RC_WAITING_ROOM) {
        if (response == Activity.RESULT_OK) {
            // (start game)         
        }
        else if (response == Activity.RESULT_CANCELED) {
            // in this example, we take the simple approach and just leave the room:
            Games.RealTimeMultiplayer.leave(mGoogleApiClient, this, mRoomId);
            getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        }
        else if (response == GamesActivityResultCodes.RESULT_LEFT_ROOM) {
            // player wants to leave the room.
            Games.RealTimeMultiplayer.leave(mGoogleApiClient, this, mRoomId);
            getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        }
    }
}

@Override
public void onDisconnectedFromRoom(Room room) {
    Log.d("MMC", "debug onDisconnectedFromRoom()");
    // leave the room
    Games.RealTimeMultiplayer.leave(mGoogleApiClient, this, mRoomId);

    // clear the flag that keeps the screen on
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    // show error message and return to main screen
}

@Override
public void onLeftRoom(int arg0, String arg1) {
    Log.d("MMC", "debug onLeftRoom() code:" + arg0);
    if(arg1!=null)
        Log.d("MMC", "debug roomId:" + arg1);
    if(!isFinishing())
        finish();       
}

@Override
public void onConnectedToRoom(Room arg0) {
    Log.d("MMC", "debug onConnectedToRoom()");
    Toast.makeText(this, "debug onConnectedToRoom", Toast.LENGTH_SHORT).show();         

}

@Override
public void onConnected(Bundle arg0) {
    // TODO Auto-generated method stub
    Log.d("MMC", "debug onConnected()");
    startQuickGame();
}

@Override
public void onStart() {
    Log.d("MMC", "debug onStart()");
    mGoogleApiClient.connect();
    super.onStart();
}

@Override
public void onStop() {
    Log.d("MMC", "debug onStop()");
    // if we're in a room, leave it.
    leave();
    mGoogleApiClient.disconnect();
    super.onStop();
  }

private void leave(){
    Log.d("MMC", "debug leave()");
    Games.RealTimeMultiplayer.leave(mGoogleApiClient, this, mRoomId);
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}

Edit 2:

I receive the same error with googles sample application ButtonClicker2000. Here is the stacktrace: [onRoomCreated(4, null) == NETWORK ERROR]

02-27 10:55:44.343: W/libjingle(1626): Warning(callregistry.cpp:27): void games_rtmp::CallRegistry::UnregisterCall(const string&, const string&): Attempting to erase non-existent session:1153730894
02-27 10:55:44.343: I/libjingle(1626): worker_thread:0xb7bdd4e0 initialized=1
02-27 10:55:44.355: I/libjingle(1626): Channel disabled
02-27 10:55:44.355: I/libjingle(1626): Changing data state, recv=0 send=0
02-27 10:55:44.363: I/libjingle(1626): Destroyed channel
02-27 10:55:44.383: V/GLSActivity(537): AuthDelegateWrapperCreated with selected intent: Intent { cmp=com.google.android.gms/.auth.DefaultAuthDelegateService }
02-27 10:55:44.391: V/GLSActivity(537): AuthDelegateWrapperCreated with selected intent: Intent { cmp=com.google.android.gms/.auth.DefaultAuthDelegateService }
02-27 10:55:44.719: I/libjingle(1626): Parsing Jingle data content
02-27 10:55:44.719: I/libjingle(1626): void gtalk::LibjingleClient::OnCallCreate(cricket::Call*): Connecting to OnAddSession
02-27 10:55:44.719: I/libjingle(1626): Calling Call::IncomingSession()
02-27 10:55:44.719: I/libjingle(1626): AddSession() called. has_data = 1
02-27 10:55:44.719: I/libjingle(1626): Creating data channel.
02-27 10:55:44.719: I/libjingle(1626): Is worker current:0
02-27 10:55:44.719: I/libjingle(1626): Current thread:0xb7c3f920
02-27 10:55:44.719: I/libjingle(1626): worker_thread:0xb7bdd4e0 initialized=1
02-27 10:55:44.719: I/libjingle(1626): Created channel for data
02-27 10:55:44.719: I/libjingle(1626): DataChannel::Init() called
02-27 10:55:44.719: I/libjingle(1626): Setting remote data description
02-27 10:55:44.719: I/libjingle(1626): Added data recv stream '' with ssrc=3755036348
02-27 10:55:44.719: I/libjingle(1626): Add remote ssrc: 3755036348
02-27 10:55:44.719: I/libjingle(1626): DataMediaChannel::SetSendBandwidth to 10485000bps.
02-27 10:55:44.719: I/libjingle(1626): Changing data state, recv=0 send=0
02-27 10:55:44.719: I/libjingle(1626): result = 1
02-27 10:55:44.719: I/libjingle(1626): void gtalk::LibjingleClient::OnAddSession(cricket::Call*, cricket::Session*): OnAddSession called.
02-27 10:55:44.723: I/libjingle(1626): Setting local data description
02-27 10:55:44.723: I/libjingle(1626): Added data send stream '' with ssrc=2649333871
02-27 10:55:44.723: I/libjingle(1626): Add send ssrc: 2649333871
02-27 10:55:44.723: I/libjingle(1626): SRTP reset to init state
02-27 10:55:44.723: I/libjingle(1626): Changing data state, recv=0 send=0
02-27 10:55:44.731: E/libjingle(1626): Error(latencyprober.cpp:83): Peer already added for reliable latency metrics.
02-27 10:55:44.731: I/libjingle(1626): Channel enabled
02-27 10:55:44.731: I/libjingle(1626): Changing data state, recv=1 send=0
02-27 10:55:44.735: I/libjingle(1626): Network Information: All networks
02-27 10:55:44.735: I/libjingle(1626): Name, Description, Prefix, Prefix Length, IP, ignored
02-27 10:55:44.735: I/libjingle(1626): ipv4-default default IPV4 network 0.0.0.0 32 10.0.3.15 0
02-27 10:55:44.735: I/libjingle(1626): eth0 eth0 192.168.169.0 24 192.168.169.101 0
02-27 10:55:44.735: I/libjingle(1626): eth1 eth1 10.0.3.0 24 10.0.3.15 0
02-27 10:55:44.735: I/libjingle(1626): eth0 eth0 fe80:: 64 fe80::a00:27ff:feff:300e 0
02-27 10:55:44.735: I/libjingle(1626): eth1 eth1 fe80:: 64 fe80::a00:27ff:fe12:f895 0
02-27 10:55:44.735: I/libjingle(1626): HttpRequest start: relay.google.com/create_session?username=s%2fLrJfwdW0xfJRKz&password=gdqF%2fWLjK3W2AZA18pjyiIj3&sn=3
02-27 10:55:44.735: I/libjingle(1626): SSL Cleanup
02-27 10:55:44.739: E/libjingle(1626): Error(basicpacketsocketfactory.cc:67): UDP bind failed with error 22
02-27 10:55:44.743: E/libjingle(1626): Error(basicpacketsocketfactory.cc:67): UDP bind failed with error 22
02-27 10:55:44.751: E/libjingle(1626): Error(basicpacketsocketfactory.cc:67): UDP bind failed with error 22
02-27 10:55:44.755: E/libjingle(1626): Error(basicpacketsocketfactory.cc:67): UDP bind failed with error 22
02-27 10:55:44.767: I/libjingle(1626): OpenSSLAdapter::OnConnectEvent
02-27 10:55:44.767: I/libjingle(1626): BeginSSL: relay.google.com
02-27 10:55:44.843: D/ButtonClicker2000(1573): onLeftRoom, code 0
02-27 10:55:44.847: I/libjingle(1626): virtual int games_rtmp::BuzzSubscriptionsTask::SetOnDisconnectTask::ProcessStart(): Send-on-disconnect: <cli:message to="[email protected]" type="headline" xmlns:cli="jabber:client"><push xmlns="google:push" channel="games.google.com/buzzbot" sendOnDisconnect="true"><recipient to="[email protected]" remove="true"/></push></cli:message>
02-27 10:55:44.855: W/libjingle(1626): Warning(libjingleclient.cpp:1175): void gtalk::LibjingleClient::TerminateAllCalls_w(): Terminating call for session:425669904
02-27 10:55:44.867: W/libjingle(1626): Warning(callregistry.cpp:27): void games_rtmp::CallRegistry::UnregisterCall(const string&, const string&): Attempting to erase non-existent session:425669904
02-27 10:55:44.867: I/libjingle(1626): worker_thread:0xb7bdd4e0 initialized=1
02-27 10:55:44.867: I/libjingle(1626): Channel disabled
02-27 10:55:44.867: I/libjingle(1626): Changing data state, recv=0 send=0
02-27 10:55:44.871: I/libjingle(1626): HttpRequest cancelled
02-27 10:55:44.871: I/libjingle(1626): SSL Cleanup
02-27 10:55:44.871: I/libjingle(1626): SSL Cleanup
02-27 10:55:44.871: I/libjingle(1626): Destroyed channel
02-27 10:55:44.875: I/libjingle(1626): worker_thread:0xb7bdd4e0 initialized=1
02-27 10:55:44.875: I/libjingle(1626): SSL Cleanup
02-27 10:55:44.987: D/dalvikvm(735): GC_CONCURRENT freed 1707K, 13% free 13343K/15303K, paused 14ms+1ms, total 165ms
02-27 10:55:50.007: W/genymotion_audio(133): out_write() limiting sleep time 46802 to 39909
02-27 10:55:50.019: V/GLSActivity(537): AuthDelegateWrapperCreated with selected intent: Intent { cmp=com.google.android.gms/.auth.DefaultAuthDelegateService }
02-27 10:55:50.019: V/GLSActivity(537): AuthDelegateWrapperCreated with selected intent: Intent { cmp=com.google.android.gms/.auth.DefaultAuthDelegateService }
02-27 10:55:50.267: D/dalvikvm(537): GC_CONCURRENT freed 927K, 11% free 10835K/12039K, paused 13ms+7ms, total 41ms
02-27 10:55:50.639: I/libjingle(1626): Token type:OAuth2
02-27 10:55:50.639: I/libjingle(1626): Final XMPP server hostname talk.google.com port to 5222
02-27 10:55:50.683: D/dalvikvm(277): GC_CONCURRENT freed 954K, 10% free 12351K/13703K, paused 14ms+1ms, total 79ms
02-27 10:55:50.723: I/libjingle(1626): OpenSSLAdapter::OnConnectEvent
02-27 10:55:50.779: I/libjingle(1626): BeginSSL: talk.google.com
02-27 10:55:50.811: W/libjingle(1626): Warning(openssladapter.cc:388): ContinueSSL -- error -1
02-27 10:55:50.811: W/libjingle(1626): Warning(openssladapter.cc:397): OpenSSLAdapter::Error(ContinueSSL, -1)
02-27 10:55:50.827: I/libjingle(1626): Token type:OAuth2
02-27 10:55:50.827: I/libjingle(1626): Final XMPP server hostname talk.google.com port to 5222
02-27 10:55:50.831: I/libjingle(1626): SSL Cleanup
02-27 10:55:50.863: I/libjingle(1626): OpenSSLAdapter::OnConnectEvent
02-27 10:55:50.915: I/libjingle(1626): BeginSSL: talk.google.com
02-27 10:55:50.943: W/libjingle(1626): Warning(openssladapter.cc:388): ContinueSSL -- error -1
02-27 10:55:50.943: W/libjingle(1626): Warning(openssladapter.cc:397): OpenSSLAdapter::Error(ContinueSSL, -1)
02-27 10:55:50.943: D/ButtonClicker2000(1573): onRoomCreated(4, null)
02-27 10:55:50.943: E/ButtonClicker2000(1573): *** Error: onRoomCreated, status 4
02-27 10:55:50.951: D/dalvikvm(735): WAIT_FOR_CONCURRENT_GC blocked 0ms
02-27 10:55:50.955: I/libjingle(1626): SSL Cleanup
02-27 10:55:50.995: D/dalvikvm(735): GC_EXPLICIT freed 239K, 14% free 13186K/15303K, paused 2ms+1ms, total 45ms
02-27 10:55:51.011: D/ChimeraCfgMgr(735): Loading module com.google.android.gms.games from APK com.google.android.play.games
02-27 10:55:51.011: D/ChimeraModuleLdr(735): Module APK com.google.android.play.games already loaded
02-27 10:55:53.243: I/libjingle(1626): Token type:OAuth2
02-27 10:55:53.243: I/libjingle(1626): Final XMPP server hostname talk.google.com port to 5222
02-27 10:55:53.275: I/libjingle(1626): OpenSSLAdapter::OnConnectEvent
02-27 10:55:53.327: I/libjingle(1626): BeginSSL: talk.google.com
02-27 10:55:53.351: W/libjingle(1626): Warning(openssladapter.cc:388): ContinueSSL -- error -1
02-27 10:55:53.351: W/libjingle(1626): Warning(openssladapter.cc:397): OpenSSLAdapter::Error(ContinueSSL, -1)
02-27 10:55:53.363: I/libjingle(1626): SSL Cleanup
02-27 10:55:53.371: I/libjingle(1626): Token type:OAuth2
02-27 10:55:53.371: I/libjingle(1626): Final XMPP server hostname talk.google.com port to 5222
02-27 10:55:53.403: I/libjingle(1626): OpenSSLAdapter::OnConnectEvent
02-27 10:55:53.459: I/libjingle(1626): BeginSSL: talk.google.com
02-27 10:55:53.487: W/libjingle(1626): Warning(openssladapter.cc:388): ContinueSSL -- error -1
02-27 10:55:53.487: W/libjingle(1626): Warning(openssladapter.cc:397): OpenSSLAdapter::Error(ContinueSSL, -1)
02-27 10:55:53.487: D/ButtonClicker2000(1573): onRoomCreated(4, null)
02-27 10:55:53.487: E/ButtonClicker2000(1573): *** Error: onRoomCreated, status 4
02-27 10:55:53.495: D/ChimeraCfgMgr(735): Loading module com.google.android.gms.games from APK com.google.android.play.games
02-27 10:55:53.495: D/ChimeraModuleLdr(735): Module APK com.google.android.play.games already loaded
02-27 10:55:53.515: I/libjingle(1626): SSL Cleanup
02-27 10:55:59.319: I/GLSUser(848): GLS error: BadAuthentication 191152222268 oauth2:https://www.googleapis.com/auth/games
02-27 10:55:59.319: V/GoogleLoginService(848): Returning error intent with: ComponentInfo{com.google.android.gsf.login/com.google.android.gsf.login.LoginActivity}
02-27 10:55:59.331: W/PlayEventLogger(735): deferring log upload because couldn't retrieve auth token
02-27 10:55:59.343: D/SizeAdaptiveLayout(399): com.android.internal.widget.SizeAdaptiveLayout@53a619b8child view android.widget.FrameLayout@53a6290c measured out of bounds at 95px clamped to 96px
like image 683
skymedium Avatar asked Feb 21 '16 01:02

skymedium


1 Answers

A checklist for you..I hope it will help you

1.check have you added Test accounts

2.check whether you turn on Realtime Multiplayer in google play developer console for your game.

3.Check required meta tags in androidMainfest file

like image 112
Rajesh.k Avatar answered Oct 16 '22 06:10

Rajesh.k