Forum Multiplayer New issue

Discussion and help relating to the PlayerIO Multiplayer API.

New issue

Postby KVADRO » August 15th, 2018, 11:05 pm

Hi! New issue.

I don't receive OnDisconnect if i connect to dev server and turn off wifi. Why is that happening?
Unity 2018.2.1f1, Latest PIO Unity SDK.

How to resolve this issue?
KVADRO
 
Posts: 16
Joined: May 6th, 2018, 8:22 pm

Re: New issue

Postby Henrik » August 18th, 2018, 10:06 am

I'm assuming you're running your dev server on a different machine that you access over this wifi, because if you're running everything on your local machine, nothing should happen. :D

However, the OnDisconnect event fires when the underlying TCP/IP connection times out, which depends on the implementation on the device you're running on. Most implementations also support resuming of connections, so if you momentarily lose your wifi, and get it back shortly, everything will keep on running and keep being connected. It takes time for a connection to time out, they don't all drop the second the device loses wifi, it takes maybe 30-60 seconds before that happens.
Henrik
.IO
 
Posts: 1822
Joined: January 4th, 2010, 1:53 pm

Re: New issue

Postby KVADRO » August 19th, 2018, 9:48 am

Hi Henrik!

I tried different approaches:
-Connect to PIO servers, 'bounce' room. After connection was established, i disable wifi on my mac. And, i never caught onDisconnect.
-Connect to PIO servers, with my custom room type. And, i also never caught onDisconnect after i disable wifi on my mac.

Unity 2018.2.1f1, Latest PIO sdk, macbook pro High Sierra.

Is this a bug?
KVADRO
 
Posts: 16
Joined: May 6th, 2018, 8:22 pm

Re: New issue

Postby KVADRO » August 19th, 2018, 12:43 pm

I tested on ios. And i saw that TCP connection was lost, but still don't receive onDisconnected.
Also, i don't receive onDIsconnected when i manually close room through dashboard, maybe this can be related to overall problem with onDisconnected?

Code: Select all
2018-08-19 14:42:10.615054+0300 ProductName[6053:3850585] TIC TCP Conn Failed [4:0x1c0178780]: 1:50 Err(50)
2018-08-19 14:42:10.654557+0300 ProductName[6053:3850585] Task <F771351C-141D-41E8-BA93-E710ABA381E1>.<0> HTTP load failed (error code: -1009 [1:50])
2018-08-19 14:42:10.654743+0300 ProductName[6053:3849871] NSURLConnection finished with error - code -1009
-> applicationDidBecomeActive()
2018-08-19 14:42:12.167362+0300 ProductName[6053:3850585] TIC TCP Conn Failed [5:0x1c0178480]: 1:50 Err(50)
2018-08-19 14:42:12.172389+0300 ProductName[6053:3850585] Task <EF45C07F-FE4D-4767-A982-32210A57076A>.<0> HTTP load failed (error code: -1009 [1:50])
2018-08-19 14:42:12.172772+0300 ProductName[6053:3850585] NSURLConnection finished with error - code -1009



Here is test code

Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PlayerIOClient;

public class tat : MonoBehaviour {

   private Client m_client;
   private Connection m_conn;
   
   // Use this for initialization
   void Start () {
      System.Random random = new System.Random();   
      string userid = "Guest" + random.Next(0, 10000);

      PlayerIO.UseSecureApiRequests = true;
      PlayerIO.Authenticate("application id"
      , "public"
      , new Dictionary<string, string>() {{ "userId", userid }}
      , null
      , delegate(Client _client)
      {
         m_client = _client;
         Multiplayer m_multiplayer = _client.Multiplayer;

         m_multiplayer.CreateJoinRoom(null
         , "ClassicPvPRoom"
         , true
         , null
         , null
         , delegate(Connection _connection)
         {
            Debug.Log("Connected");

            m_conn = _connection;
            m_conn.OnMessage += delegate(object _sender, Message _msg)
            {
               Debug.Log(_msg.ToString());

            };

            m_conn.OnDisconnect += delegate(object _sender, string _str)
            {
               Debug.Log("DIsconnected");
            };
         }
         , delegate(PlayerIOError _error)
         {
            Debug.Log("Can't connect");
         });
      }
      , delegate(PlayerIOError _error)
      {
         Debug.Log("Can't auth");
      });
   }
   
   // Update is called once per frame
   void Update () {
      
   }
}
KVADRO
 
Posts: 16
Joined: May 6th, 2018, 8:22 pm

Re: New issue

Postby KVADRO » September 7th, 2018, 4:18 pm

Hi...
Any updates on this, please?
KVADRO
 
Posts: 16
Joined: May 6th, 2018, 8:22 pm

Re: New issue

Postby Henrik » September 8th, 2018, 6:26 am

The way OnDisconnect works in the C# client libraries, is that it will fire if sending a Message through the Connection times out or fails.

So if you just join a room, and setup a disconnect handler, and disable the wifi, nothing wil happen. You have to be actively sending messages through the connection for it to fire.
Henrik
.IO
 
Posts: 1822
Joined: January 4th, 2010, 1:53 pm

Re: New issue

Postby KVADRO » September 15th, 2018, 12:32 pm

Ok, can i change 'TCP send timeout' for Connection object?
Because right now i should wait from (1.5) to (4) minutes to OnDisconnect be fired, i want to change delay to 30 sec. How can i do that?
KVADRO
 
Posts: 16
Joined: May 6th, 2018, 8:22 pm

Re: New issue

Postby KVADRO » September 15th, 2018, 7:14 pm

Another interesting situation.
I call CreateJoinRoom and disable wifi connection. And, error delegate never fired.
I don't have Connection object to constantly send data (as you said previously). How to deal with this?
KVADRO
 
Posts: 16
Joined: May 6th, 2018, 8:22 pm


Return to Multiplayer



cron