Mirror icon indicating copy to clipboard operation
Mirror copied to clipboard

Setting NetworkServer.dontListen to true after starting server doesn't close socket properly

Open CorneliusCornbread opened this issue 5 years ago • 5 comments

Describe the bug So this was an issue I was dealing with for a long time. I eventually figured out that the socket wasn't being closed because the NetworkServer skips closing the socket if NetworkServer.dontListen is true. What makes this more frustrating is that Telepathy doesn't have this issue. KCP does and I believe that this was the reason why I was getting issues with Ignorance, mentioned here: https://github.com/SoftwareGuy/Ignorance/issues/60#issuecomment-654042619

Repro project https://drive.google.com/file/d/1b9EdHud78aeqbol2mucnleX9ndbOoF9V/view?usp=sharing

To Reproduce Steps to reproduce the behavior:

  1. Open the attached project
  2. Open the sample scene
  3. Select the NetworkManager
  4. Hit the Bugged Start Host button on the BugReproduction component
  5. Hit the Stop Host button
  6. Hit the Bugged Start Host button again and error

Expected behavior At the very least if you set NetworkServer.dontListen to true when you've started a server already you should get an error.

Desktop (please complete the following information):

  • OS: Windows 10
  • Build target: Windows
  • Unity version: 2019..4.16f1
  • Mirror branch: Asset store latest as of 1/8/2021 (30.2.1)

CorneliusCornbread avatar Jan 08 '21 17:01 CorneliusCornbread

The don't listen logic might actually be jank. I'll see if I can trace the feature and see if there's room for improvement.

SoftwareGuy avatar Jan 10 '21 02:01 SoftwareGuy

dontListen is not supposed to be modified at runtime. but yea maybe some kind of error or w/e later makes sense

miwarnec avatar Mar 06 '21 13:03 miwarnec

dontListen is not supposed to be modified at runtime. but yea maybe some kind of error or w/e later makes sense

Perhaps dontListen should have a setter that shuts down the listening.

MrGadget1024 avatar Jun 12 '21 12:06 MrGadget1024

dontListen is not supposed to be modified at runtime. but yea maybe some kind of error or w/e later makes sense

Perhaps dontListen should have a setter that shuts down the listening.

Ideally, I think it'd be best to somehow make it so that variables that should not be modified at runtime should not be able to be accessed during runtime. Say instead you pass an argument when starting a client/server/host. Though I'd imagine this'd be more effort than it's worth to make happen.

CorneliusCornbread avatar Jul 07 '21 21:07 CorneliusCornbread

Not fixed

MrGadget1024 avatar Jul 15 '21 06:07 MrGadget1024