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 /
  • Help Room /
avatar image
0
Question by Glicknork · Aug 15, 2017 at 12:53 PM · multiplayer-networkingdisconnectmessagestimeoutbandwidth

Online multiplayer bandwidth timeout no free events issue

Looking for advice from someone experienced with online networking optimization in Unity.

My friend and I have been building a multiplayer game for the past year, which we have gotten Greenlit and we are now very close to release on Steam. The game is a 2d shooter that supports up to 4 players, who fight waves of enemies, buy weapons, blow stuff up, etc. It means there is a lot of on-screen action all the time, much of which is using Network Transform syncvar updates, sending Commands and ClientRpcs, etc. We initially designed it to work only on LAN, but recently decided to go for online play using Unity's matchmaking service. This has opened up a can of worms, as we found that we needed to totally re-optimize the game to account for the slower bandwidth. I have systematically made everything I can client-based: bullets, explosions and even the enemies now operate only on the clients, with only key pieces of data being sent over the network to keep things in sync. When running with the profiler on network operations and messages tend to peak at around 60 (it used to go up to over 300, which is when we would get timeouts).

However, despite all the optimization we are still faced with timeout disconnects when playing online via Unity's multiplayer service. The error is usually a classic network timeout. In response to this I have changed the advanced settings in the Network Manager, increasing the disconnect thresholds. This resolved the timeout issue, BUT replaces it with another: "no free events for long message in the event queue"

From what I have found online I think that this means I have created too much of a buffer for messages to pile up before being sent. The advanced settings I am currently using in the Network Manager, which are the best I can get to minimize (but not elminate) timeouts and the 'no free event' error, are:

Min Update Timeout: 30 milliseconds Connection Timeout: 2000 milliseconds Disconnect Timout: 6000 milliseconds Ping Timeout: 2000 milliseconds

Reactor Max Rec Messages: 8192 Reactor Max Sent Messages: 8192

If these settings are set lower I generally get disconnect timeouts on clients when there's a lot of action. If they are set higher I get no free events errors on the host, with eventual timeouts for the clients, normally after a few minutes. I have only a rudimentary understanding of what these settings mean, and I have found very limited resources online. I would hugely appreciate it if somebody with a better understanding of what these settings mean could help explain what I might be doing wrong.

The only other thing I have considered is that maybe we simply need more bandwidth than Unity's free multiplayer service provides. We have looked into Going Live, at which point we will be paying for bandwidth. However I was shocked to find that at 4.5kbps per user (the standard recommended by Unity, and only 0.5kbps more than we currently get for free), we could be paying anything from $200-$2,600 a month for 500 users! We are not intending on selling the game for much so this looks totally unfeasible. I cant believe that our relatively simple indie game could be using that much bandwidth.... so I am hoping that it is to do with the above mentioned settings issues that we are getting disconnects, not because we actually need that much traffic.

Thanks in advance to anyone who might be able to offer some advice!

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Glicknork · Dec 17, 2017 at 11:53 PM

FYI for anybody who gets this issue in the future. I managed to eventually fix it with the help of Unity guru aabramychev. He gave me some improved settings for how I was setting up the network topography (which I had never been able to find elsewhere in the documentation). These are the initialization settings that worked for us:

void InitializeNetwork(){ myConfig.AddChannel(QosType.Reliable); myConfig.AddChannel(QosType.Unreliable); myConfig.AddChannel(QosType.StateUpdate); myConfig.AddChannel(QosType.AllCostDelivery); myConfig.NetworkDropThreshold = 95; //95% packets that need to be dropped before connection is dropped myConfig.OverflowDropThreshold = 30; //30% packets that need to be dropped before sendupdate timeout is increased
myConfig.InitialBandwidth = 0; myConfig.MinUpdateTimeout = 10; myConfig.ConnectTimeout = 2000; // timeout before re-connect attempt will be made myConfig.PingTimeout = 1500; // should have more than 3 pings per disconnect timeout, and more than 5 messages per ping myConfig.DisconnectTimeout = 6000; // with a ping of 500 a disconnectimeout of 2000 is supposed to work well myConfig.PacketSize = 1470; myConfig.SendDelay = 2; myConfig.FragmentSize = 1300; myConfig.AcksType = ConnectionAcksType.Acks128; myConfig.MaxSentMessageQueueSize = 256; myConfig.AckDelay = 1; HostTopology myTopology = new HostTopology(myConfig, 4); //up to 4 connection allowed
NetworkServer.Configure(myTopology); }

Comment
Add comment · Show 3 · 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 IgorAherne · Feb 11, 2020 at 09:02 PM 0
Share

God bless u

avatar image Clicksurfer · Apr 23, 2020 at 07:17 PM 0
Share

Hey there, thanks for the post. I have the exact same issue you had, stem$$anonymous$$g from the exact same situation ($$anonymous$$ade a LAN game, eventually transformed into online), however I am using HLAPI, so I'm not so sure where or how I can configure these values in my code. Any idea how I could do that? Will I need to fully transition to LLAPI? Thanks in advance

avatar image Glicknork Clicksurfer · May 14, 2020 at 03:00 PM 0
Share

Hey @Clicksurfer . I did this a long time ago, so my memory of all the details isn't great. However I was also using HLAPI in conjunction and this still worked. I was able to achieve it by defining a new network topology at runtime. Just copy/paste the code above into Start and it should hopefully get you somewhere.

However as Unity is pulling support for UNET now I would advise moving on to a new API like Photon. I wish I had used Photon to begin with, it's so much easier and doesn't have bandwidth limitations you run into with Unity's relay servers.

avatar image
0

Answer by Bryan-Legend · Jun 20, 2020 at 12:47 AM

Try a higher port number on Ubuntu. 17000 works but 1700 does not.

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

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

113 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity server disconnects after a few minutes 0 Answers

Will matchmaking cost me money if i do not publish my game and just use it personally for college project? There will only be one room with 4 players in the scene. 0 Answers

How do I implement a message based network system UNITY 5? 0 Answers

How do you correctly remove a player that has disconnected from a game when using "OnServerDisconnect" ? 0 Answers

multi monitor Application 0 Answers


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