Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Nimred · May 10, 2016 at 08:29 PM · networkmultiplayer-networkingdisconnecttimeout

How to avoid P2P disconnects every 40 seconds?

I'm using the NetworkTransport API for a turn-based game, in pretty much the same way as this tutorial explains: http://www.robotmonkeybrain.com/good-enough-guide-to-unitys-unet-transport-layer-llapi/

I have only two players, they successfully connect to each other by IP (not matchmaking), and successfully exchange messages every second or so.

However, every 40-50 seconds, the clients receive "Disconnect" messages, with the error number 6, aka "Timeout". The disconnects don't happen simultaneously on each client. Every time I restore the connection following the disconnect, but another disconnect comes 40-50 seconds after connection is established.

  • I tried to crank up all sorts of timeouts in the ConnectionConfig class, without effect. Also, none of the timeout values I checked correspond to 40-50 seconds

  • I tried clients on the same local network and different networks, without effect (except in the timeout value, which was exactly every 37-38 seconds on different networks, but was variable between 40-50 on LAN). It also happens when both clients are on the same computer.

  • I tried different channel types: Reliable (which is what I want), Unreliable, AllCostDelivery. It made no difference.

  • I looked up the forums, google, answers, but while others seem to have similar problems, no solution has been mentioned.

I don't think I'm doing anything wrong, unexpected or special with my code. Pretty much basic peer to peer. Does anyone know if this is a bug with Unity, or if there's a hidden setting that must be changed in order to make multiplayer work?

PS: I'm on Unity 5.3.3f1

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image firest-dead · Oct 08, 2020 at 12:23 PM 0
Share

Implement a heartbeat.

Send a ping packet over the socket once per few seconds, return a pong back when the other side receives a ping. You can use this to track if the connection is alive and the network latency. It will also keep the connection alive. In real time games, the games will generate a lot of frequent traffic that will keep the connection alive, but in turn based games - the connection will disconnect when idle.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Nimred · May 26, 2016 at 01:36 PM

I got an answer on the forum: http://forum.unity3d.com/threads/networktransport-disconnect-every-40-seconds.403563/

In my case increasing the network drop threshold mostly fixed the issue.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by josephsaade · May 26, 2016 at 01:03 PM

I am having the same issue but with match making with NetworkManager.

My game is a multiplayer card game, so it does not send a lot of messages over the network (only when a card is placed) but there would be 30-seconds to 1 minute where the player is just thinking.

What I noticed is that if I leave the players in Idle state they get disconnected after about 40 to 50 seconds.

But if I send messages that disconnect gets postponed a bit, but that does not completely stop random disconnects.

I do not know the type of game you are making, but did you try sending a ping message between players every second or so?

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Nimred · May 26, 2016 at 01:38 PM 0
Share

$$anonymous$$y turn based game sent messages every few seconds, that did not help with the disconnects. Seems to have been a packet drop issue (see answer)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

52 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

UNet NetworkManager Client Disconnect : After OnApplicationFocus 1 Answer

Spawn Cube doesnt Show up on client. (Unity Networking) 0 Answers

Unity networking solution (PUN or Bolt) 0 Answers

custom spawn unet weird behaviour ? 0 Answers

network player only flip on LAN Host not in Lan Client 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges