Author Topic: no valid socket  (Read 8271 times)

creativitysquare

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 2
  • Posts: 41
    • View Profile
no valid socket
« on: June 11, 2015, 04:40:41 PM »
had issue with il2cpp

now i am on latest version of unity and of tnet but i get from time to time "no valid socket warning" and from the phone doesnt work and the whole connection process goes very slow.

any idea?

in my code i do this:
  1. void Update () {
  2.                 if (Application.loadedLevelName == NUtils.LOBBY_SCENE) {
  3.                                
  4.                         if (Time.time > NextRefreshUpdate)
  5.                         {
  6.                                 if (SERVER_CONNECTED)
  7.                                 {
  8.                                         TNManager.client.BeginSend(Packet.RequestChannelList);
  9.                                         TNManager.client.EndSend();
  10.                                 }
  11.                                 NextRefreshUpdate = Time.time + RefreshOffsetRate;
  12.                         }
  13.                 }
  14.         }
  15.  
and i get a lot of no valid socket while i stay in the scene ready to click to connect to the server.
the line triggering the no valid socket is : TNManager.client.EndSend();

the no valid socket comes from this class:
  1. public class TcpProtocol : Player....
  2. ...
  3.                 }
  4.                 else
  5.                 {
  6. #if UNITY_EDITOR
  7.                         UnityEngine.Debug.LogWarning("No valid socket");
  8. #endif
  9.                         buffer.Recycle();
  10.                 }
  11.         }
  12.  
« Last Edit: June 11, 2015, 05:02:52 PM by creativitysquare »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: no valid socket
« Reply #1 on: June 12, 2015, 08:14:04 AM »
What's the full call stack of the warning? As you can see that warning will only show up if the socket is not valid, or it's not connected. TCP communication requires a valid, active connection.

creativitysquare

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 2
  • Posts: 41
    • View Profile
Re: no valid socket
« Reply #2 on: June 12, 2015, 01:44:49 PM »
  1. No valid socket
  2. UnityEngine.Debug:LogWarning(Object)
  3. TNet.TcpProtocol:SendTcpPacket(Buffer) (at Assets/TNet/Common/TNTcpProtocol.cs:477)
  4. TNet.GameClient:EndSend() (at Assets/TNet/Client/TNGameClient.cs:515)
  5. NMyConnectionManager:Update() (at Assets/_MyScripts/NMyConnectionManager.cs:73)
  6.  
  7.  
beside the random warning it works ok. For some reason doesnt pick up the first time the guestname but i think is my problem.

By the way how do i replace
  1. TNManager.Destroy(gamboject)
which is now deprecated?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: no valid socket
« Reply #3 on: June 12, 2015, 04:09:50 PM »
tno.DestroySelf();

What's in your NMyConnectionManager.Update()? Are you checking to make sure that TNManager.isConnected before doing your packet send?

creativitysquare

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 2
  • Posts: 41
    • View Profile
Re: no valid socket
« Reply #4 on: June 14, 2015, 06:49:25 AM »
Obviously i just have to derive from TNBehaviour :)
thanks

About the warning in the update i was checking the connection but i forgot to set my local variable to false when i disconnect so my bad sorry

« Last Edit: June 14, 2015, 11:51:40 AM by creativitysquare »