question

256199 avatar image
256199 asked

Build stuck on initialized if server is not started from OnServerActive

Hi, I have an issue where the server is stuck on Initialized. When I change it so the StartServer() method from NetworkManager (mirror) is called in OnServerActive listener, it works fine. But the issue is that when I change it matchcmaking can’t get port and IP (i assume the server is not active when a match has been found). Here’s the code of my ServerStartup script:

https://pastebin.com/2UgqgwQs

Here’s network manager:

https://pastebin.com/4VPBBU6J

And here’s matchmaking:

https://pastebin.com/Nh77i3im

I’ve tried to follow Gsdk samples but server won’t start when running it from OnServerActive(). I think I need to wait until server becomes active and then get the port and set it to NetworkManager so it connects, but I have no idea how to do so.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

256199 avatar image
256199 answered

Ok, I found the issue. In my NetworkManager from mirror's side I have an offline scene which doesn't have this startup script. So, when starting the server, it goes directly to this scene and can't finish initialization. Simple fix - move StartServer to OnServerActive and wait a little so it can finish starting server up.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Xiao Zha avatar image
Xiao Zha answered

Since the server build will turn to active after you request the server instance. And according to your code, you have chosen to let the matchmaking queue automatically allocate server instances for you. If so, in order to request and get the server instance, have you checked the "Enable server allocation" checkbox in the matchmaking queue.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

256199 avatar image 256199 commented ·

Hi, I enabled server allocation, since I used it before, it was never an issue, I might have forgot to mention this. The issue is that the build is stuck on initialized. When I move mirror's StartServer() to OnServerActive listener, it works fine (goes to standby). I assume it can't reach ReadyForPlayers coroutine, since the server is starting before it. But, when I move StartServer() to OnServerActive listener, it's not ready to accept clients from mirror's side and I get an NullReference in OnGetMatch callback (so I guess it can't find IP and port)

0 Likes 0 ·
256199 avatar image 256199 256199 commented ·

Here are the logs on my instance. I've added debug.log for when ReadyForPlayers is called, and for StartServer method.

0 Likes 0 ·
256199 avatar image
256199 answered

Here are the logs which I forgot to upload in answer


10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.