The PC does not connect to the host on the smartphone in the same wifi network

I am using Unity 6000.0.32f1.
When I try to connect to the server that I created on my smartphone, an error occurs and I cannot connect.
However, creating a host and connecting the client to the created server is perfect.
The Unity console writes the following:

All socket receive requests were marked as failed, likely because socket itself has failed.
0x00007ff9a68016ee (Unity) Stacktrace::GetStacktrace
0x00007ff9a4d61b3a (Unity) DefaultBurstRuntimeLogCallback
0x00007ff9a466539a (Unity) BurstCompilerService_CUSTOM_RuntimeLog
0x00007ff9f7faa622 (690ca5aa611b4bd698ddfeda7798497) Unity.Jobs.IJobExtensions.JobStruct`1<Unity.Networking.Transport.UDPNetworkInterface.ReceiveJob>.Execute(ref Unity.Networking.Transport.UDPNetworkInterface.ReceiveJob data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, ref Unity.Jobs.LowLevel.Unsafe.JobRanges ranges, int jobIndex) -> void_1a17c9416545ae7079718413b8a5101d from UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null (at D:/Unity/Projects/SurvMine/Library/PackageCache/com.unity.burst/.Runtime/unknown/unknown:0)
0x00007ff9f7fa865d (690ca5aa611b4bd698ddfeda7798497) d405243e08c5a10bb107ab8ae84cf799
0x00007ff9a50ac3c5 (Unity) ExecuteJob
0x00007ff9a50ad4dd (Unity) ForwardJobToManaged
0x00007ff9a50a96a9 (Unity) ujob_execute_job
0x00007ff9a50a8a9f (Unity) lane_guts
0x00007ff9a50ab714 (Unity) worker_thread_routine
0x00007ff9a52a157d (Unity) Thread::RunThreadWrapper
0x00007ffa5be6e8d7 (KERNEL32) BaseThreadInitThunk
0x00007ffa5deffbcc (ntdll) RtlUserThreadStart
Socket error encountered; attempting recovery by creating a new one.
UnityEngine.Debug:LogWarning (object)
Unity.Networking.Transport.UDPNetworkInterface:RecreateSocket (long,Unity.Networking.Transport.PacketsQueue&) (at ./Library/PackageCache/com.unity.transport/Runtime/UDPNetworkInterface.cs:598)
Unity.Networking.Transport.UDPNetworkInterface:ScheduleReceive (Unity.Networking.Transport.ReceiveJobArguments&,Unity.Jobs.JobHandle) (at ./Library/PackageCache/com.unity.transport/Runtime/UDPNetworkInterface.cs:481)
Unity.Networking.Transport.NetworkInterfaceLayer`1<Unity.Networking.Transport.UDPNetworkInterface>:ScheduleReceive (Unity.Networking.Transport.ReceiveJobArguments&,Unity.Jobs.JobHandle) (at ./Library/PackageCache/com.unity.transport/Runtime/Layers/NetworkInterfaceLayer.cs:59)
Unity.Networking.Transport.NetworkLayerWrapper:ScheduleReceiveWrapper<Unity.Networking.Transport.NetworkInterfaceLayer`1<Unity.Networking.Transport.UDPNetworkInterface>> (void*,int) (at ./Library/PackageCache/com.unity.transport/Runtime/NetworkLayerWrapper.cs:102)
Unity.Networking.Transport.ManagedCallWrapper:Method (void*,void*,int) (at ./Library/PackageCache/com.unity.transport/Runtime/Utilities/ManagedCallWrapper.cs:22)
Unity.Networking.Transport.ManagedCallWrapper:Invoke (void*,int) (at ./Library/PackageCache/com.unity.transport/Runtime/Utilities/ManagedCallWrapper.cs:60)
Unity.Networking.Transport.ManagedCallWrapper:Invoke<Unity.Networking.Transport.NetworkLayerWrapper/ScheduleReceiveArguments> (Unity.Networking.Transport.NetworkLayerWrapper/ScheduleReceiveArguments&) (at ./Library/PackageCache/com.unity.transport/Runtime/Utilities/ManagedCallWrapper.cs:67)
Unity.Networking.Transport.NetworkLayerWrapper:ScheduleReceive (Unity.Networking.Transport.ReceiveJobArguments&,Unity.Jobs.JobHandle) (at ./Library/PackageCache/com.unity.transport/Runtime/NetworkLayerWrapper.cs:87)
Unity.Networking.Transport.NetworkStack:ScheduleReceive (Unity.Networking.Transport.NetworkDriverReceiver&,Unity.Networking.Transport.ConnectionList&,Unity.Networking.Transport.NetworkEventQueue&,Unity.Networking.Transport.NetworkPipelineProcessor&,Unity.Collections.NativeHashMap`2<Unity.Networking.Transport.ConnectionId, Unity.Networking.Transport.ConnectionPayload>&,long,Unity.Jobs.JobHandle) (at ./Library/PackageCache/com.unity.transport/Runtime/NetworkStack.cs:345)
Unity.Networking.Transport.NetworkDriver:ScheduleUpdate (Unity.Jobs.JobHandle) (at ./Library/PackageCache/com.unity.transport/Runtime/NetworkDriver.cs:714)
Unity.Netcode.Transports.UTP.UnityTransport:OnEarlyUpdate () (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs:964)
Unity.Netcode.NetworkTransport:EarlyUpdate () (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Transports/NetworkTransport.cs:126)
Unity.Netcode.NetworkManager:NetworkUpdate (Unity.Netcode.NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs:324)
Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Core/NetworkUpdateLoop.cs:191)
Unity.Netcode.NetworkUpdateLoop/NetworkEarlyUpdate/<>c:<CreateLoopSystem>b__0_0 () (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Core/NetworkUpdateLoop.cs:214)
Failed to connect to server.
UnityEngine.Debug:LogError (object)
Unity.Netcode.Transports.UTP.UnityTransport:ProcessEvent () (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs:924)
Unity.Netcode.Transports.UTP.UnityTransport:OnEarlyUpdate () (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs:973)
Unity.Netcode.NetworkTransport:EarlyUpdate () (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Transports/NetworkTransport.cs:126)
Unity.Netcode.NetworkManager:NetworkUpdate (Unity.Netcode.NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs:324)
Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Core/NetworkUpdateLoop.cs:191)
Unity.Netcode.NetworkUpdateLoop/NetworkEarlyUpdate/<>c:<CreateLoopSystem>b__0_0 () (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Core/NetworkUpdateLoop.cs:214)

image

And these logs are displayed until it is written that it was not possible to connect to the server.

This reads like you are calling StartServer() on the smartphone. That would be so impractical that I’d say it’s not even supported. But perhaps there’s just a comma missing.

Could you please be precise as to which device/instance is the host/server and with which you want to connect, and from which instances these logs are from?

If you can’t connect from the smartphone to your PC, check if your router is in Wifi isolation mode (can’t see/access other devices) or if the smartphone is connected to guest wifi (pretty much the same as wifi isolation plus additonal restrictions).

However, it would be wrong not to clarify this point about the server on the smartphone. The fact is that I create a host on my smartphone by calling the StartHost() method.
This problem occurs when I try to connect from two computers that are already connected via LAN to the same subnet of my home router.
That is, it doesn’t matter who is the host and who is the client. Devices in the client role always receive such logs.

So the smartphone is the Host device, the desktop instances are the clients which can’t connect to the host?

Can you connect if one of the desktop computers is hosting? Because if not, the issue is probably related to the address/port/serverlistenaddress parameters.

If the computers can connect, it’s most likely an issue with the computers not being able to communicate with the smartphone. Since the computers are on LAN but the smartphone is on Wifi they are technically in two different subnets, thus port forwarding is required on the wifi router in order to connect.

However, the PC can see the smartphone in the lobby list. The same can be seen if one of the hosts is a computer from LAN.
Moreover, computers from the same LAN cannot connect, giving the same error described earlier.

The lobby list is obtained using the following method:


 public async UniTask<QueryResponse> LookUpLobbies()
        {
            var options = new QueryLobbiesOptions
            {
                Count = 25,
                // Filter for open lobbies only
                Filters = new List<QueryFilter>()
                {
                    new(
                        QueryFilter.FieldOptions.AvailableSlots,
                        op: QueryFilter.OpOptions.GT,
                        value: "0")
                },
                // Order by newest lobbies first
                Order = new List<QueryOrder>()
                {
                    new(
                        false,
                        QueryOrder.FieldOptions.Created)
                }
            };
            if (_queryCooldown.TaskQueued)
                return null;
            await _queryCooldown.QueueUntilCooldown();
            try
            {
                var queryLobbiesAsync = await Lobbies.Instance.QueryLobbiesAsync(options);
                return queryLobbiesAsync;
            }
            catch (Exception e)
            {
                _messageManager.ShowMessage(MessageType.Ok, "Error lookup lobbies", $"{e}", MessageIcon.Error,
                    toTranslateDesc: false);
                return null;
            }
        }

The Lobby is a cloud service, any device can connect to a remote server and exchange data.

You can use the Relay service to allow the desktop clients to connect to the smartphone. This relays the communication via a cloud service much like the Lobby service.

But if your intention is to make a direct connection without a Relay service, you certainly have to set up port forwarding on the router to allow LAN devices to connect to Wifi devices or vice versa.

1 Like

Thank you very much! I’ll try to connect using Relay.

Hi,

here is the code i am using on Unity Editor, like i want to make 1 “Play” button. And first client will check if any room is there then start as a client, And if no room is there then start as a host.

But Getting this error continues after trying to join, Also can’t host after delay. Please Help

“All socket receive requests were marked as failed, likely because socket itself has failed.”

public void Connect()
 {
     NetworkManager.Singleton.StartClient();

     Invoke(nameof(Check), 4);
 }

 private void Check()
 {
     if (NetworkManager.Singleton.IsConnectedClient)
     {
         Debug.Log("Not");
     }
     else
     {
         Debug.Log("Hosting");
         NetworkManager.Singleton.StartHost();
     }
 }

Don’t!

You don’t wait “some time” and expect something to be complete or not in networking. Instead, register for the appropriate callbacks.

You can’t host because the client is already connecting. IsConnectedClient may be false but that is the state of the client actually being connected to a host, it would still be in the state of trying to connect. If anything, you’d have to check for IsClient and IsListening.