Author Topic: Socket null exception error  (Read 1507 times)

ibaanb

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 17
    • View Profile
Socket null exception error
« on: February 18, 2015, 08:03:34 AM »
Hi,

After using this function TNManager.StartUDP() and enabling TNLobbyClient in TNUdpLobbyClient.cs, sometimes this error would occur: "InvalidOperationException: The socket is null. Did you forget to call UdpProtocol.Start()?" at TNet.UdpProtocol.Send() in TNUdpProtocol.cs.
I would like to know what causes this error because it does not happen 100% and how to fix it because after appearing it is not possible to continue playing the game.

Thanks,

Pathompong Nakpathom

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: Socket null exception error
« Reply #1 on: February 18, 2015, 04:42:00 PM »
What version of TNet are you using? I vaguely remember something like that happening maybe a year ago, but I haven't heard of anything since. The socket is created inside StartUDP(). Did you check to see if it actually succeeded in creating the socket at all?

ibaanb

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 17
    • View Profile
Re: Socket null exception error
« Reply #2 on: February 19, 2015, 12:07:26 AM »
I using Tasharen version 1.9.9. I discovered that error is occur when I enabling TNLobbyClient in TNUdpLobbyClient.cs. If start function failed in the first time (line 56) then the socket is null is detected when TNUdpLobbyClient use update function to send Udp data (line 149).

ibaanb

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 17
    • View Profile
Re: Socket null exception error
« Reply #3 on: February 19, 2015, 04:05:47 AM »
I tried to check the exception message when I start Udp function (TNUdpLobbyClient.cs : line 56), it will show "Access denied" 2 times before socket is null. However, if it works, the second call start function will not have an exception.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: Socket null exception error
« Reply #4 on: February 19, 2015, 05:27:42 PM »
You need to update to the latest version.

Bradamante3D

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 79
    • View Profile
Re: Socket null exception error
« Reply #5 on: October 28, 2016, 03:29:53 PM »
It seems I have a similiar problem. This thread is the only thread Google finds in the context of "Access Denied" and TNet. See the attached screenshot.

The console says:

Quote
Access denied
UnityEngine.Debug:LogError(Object)
TNet.TcpProtocol:RespondWithError(Buffer, String) (at Assets/Libraries/TNet/Common/TNTcpProtocol.cs:923)
TNet.TcpProtocol:RespondWithError(String) (at Assets/Libraries/TNet/Common/TNTcpProtocol.cs:897)
TNet.TcpProtocol:OnConnectResult(IAsyncResult) (at Assets/Libraries/TNet/Common/TNTcpProtocol.cs:321)
System.Net.Sockets.Worker:Connect()

Access denied
UnityEngine.Debug:LogWarning(Object)
TNet.TNTcpLobbyClient:Update() (at Assets/Libraries/TNet/Client/TNTcpLobbyClient.cs:100)

every two seconds or something. This is in my main menu, after hitting Play. There's nothing going on, I only have the "Network Lobby Listeners" GameObject in my Hierarchy. I assume that the calls are coming from there, but who knows.

TNet is 3.0.5 with Unity 5.4.1 on OS X.
#301224014, #301432336, #302399130

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: Socket null exception error
« Reply #6 on: October 30, 2016, 12:59:45 PM »
So where is your lobby client set to connect to? Wherever that it, seems like it's not accessible.