Author Topic: TNAutoJoin: "Exception has been thrown" error on every single example  (Read 2197 times)

bac9

  • Full Member
  • ***
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 113
    • View Profile
I have just started learning TNet and I'm encountering a strange issue with TNAutoJoin that was used in the second TNet tutorial and in an example scene. Any attempt to start the game is interrupted by the following error:

  1. Exception has been thrown by the target of an invocation. (TNAutoJoin.OnNetworkConnect)
  2. UnityEngine.Debug:LogError(Object, Object)
  3. TNet.UnityTools:Broadcast(String, Object[]) (at Assets/TNet/Client/TNUnityTools.cs:216)
  4. TNManager:OnConnect(Boolean, String) (at Assets/TNet/Client/TNManager.cs:977)
  5. TNet.GameClient:ProcessPacket(Buffer, IPEndPoint) (at Assets/TNet/Client/TNGameClient.cs:665)
  6. TNet.GameClient:ProcessPackets() (at Assets/TNet/Client/TNGameClient.cs:633)
  7. TNManager:Update() (at Assets/TNet/Client/TNManager.cs:962)

The server logs the connection, though. I've tried checking a few options like changing IP and ports of the server in the server config and TNAutoJoin inspector, but those parameters don't seem to be related to the issue. What else could be happening and is there a way to make the "Exception has been thrown by the target of an invocation." error more informative? (I've seen lots of very varied cases on the net mentioning it, none applying to the situation as far as I see, so it might be a generic error covering very broad amount of potential reasons)

Update: Rechecked it on an empty project, the error is not happening, so it's most likely down to differences in TNAutoJoin public parameters I was attempting to use. The question about making "Exception" error more informative still stands though, as I'm pretty much in the blind about the cause.

Update2: Reimporting TNet somehow fixed the issue, examples now open even in the current project. Not sure if issue is related or not, but I'm now getting a strange error in the server log that doesn't seem to affect the connection:

  1. 127.0.0.1:3806 has connected
  2. The requested address is not valid in its context.
  3.  

This happens on every single connection I make with the server and a client situated on the same PC.
« Last Edit: June 17, 2014, 01:00:50 PM by bac9 »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
"Exception has been thrown" means that TNet sent your failure function name a broadcast message, and your function did something inside that caused an exception.

Can't say I've seen the "requested address is not valid" message before though.

bac9

  • Full Member
  • ***
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 113
    • View Profile
Okay, I ignored the "requested address is not valid" message yesterday, moved the project to a different PC to continue working on it, and pulled the repo on the first PC right now. The message is not appearing anymore, for whatever reason. Maybe it was some harmless quirk of Windows/hardware and not something in the code. So I guess that problem is solved, heh.