ERROR: SocketException: The operation completed successfully.

I get this error spammed whenever I enter playmode or rebuild scripts. This is really problematic getting used to always having 1 error always in the log.

This is the call stack:

SocketException: The operation completed successfully.

System.Net.Sockets.Socket..ctor (System.Net.Sockets.AddressFamily addressFamily, System.Net.Sockets.SocketType socketType, System.Net.Sockets.ProtocolType protocolType) (at <0463b2ef957545c0a51b42f372cd4fbb>:0)
System.Net.NetworkInformation.Ping.SendPrivileged (System.Net.IPAddress address, System.Int32 timeout, System.Byte[ ] buffer, System.Net.NetworkInformation.PingOptions options) (at <0463b2ef957545c0a51b42f372cd4fbb>:0)
System.Net.NetworkInformation.Ping.Send (System.Net.IPAddress address, System.Int32 timeout, System.Byte[ ] buffer, System.Net.NetworkInformation.PingOptions options) (at <0463b2ef957545c0a51b42f372cd4fbb>:0)
System.Net.NetworkInformation.Ping.Send (System.String hostNameOrAddress, System.Int32 timeout, System.Byte[ ] buffer, System.Net.NetworkInformation.PingOptions options) (at <0463b2ef957545c0a51b42f372cd4fbb>:0)
System.Net.NetworkInformation.Ping.Send (System.String hostNameOrAddress, System.Int32 timeout, System.Byte[ ] buffer) (at <0463b2ef957545c0a51b42f372cd4fbb>:0)
System.Net.NetworkInformation.Ping.Send (System.String hostNameOrAddress, System.Int32 timeout) (at <0463b2ef957545c0a51b42f372cd4fbb>:0)
(wrapper remoting-invoke-with-check) System.Net.NetworkInformation.Ping.Send(string,int)
UnityEditor.AddressableAssets.HostingServices.HostingServicesManager.FilterValidIPAddresses (System.Collections.Generic.List`1[T] ipAddresses) (at Library/PackageCache/com.unity.addressables@1.18.16/Editor/HostingServices/HostingServicesManager.cs:481)
UnityEditor.AddressableAssets.HostingServices.HostingServicesManager.RefreshGlobalProfileVariables () (at Library/PackageCache/com.unity.addressables@1.18.16/Editor/HostingServices/HostingServicesManager.cs:352)
UnityEditor.AddressableAssets.HostingServices.HostingServicesManager.OnEnable () (at Library/PackageCache/com.unity.addressables@1.18.16/Editor/HostingServices/HostingServicesManager.cs:276)
UnityEditor.AddressableAssets.Settings.AddressableAssetSettings.OnEnable () (at Library/PackageCache/com.unity.addressables@1.18.16/Editor/Settings/AddressableAssetSettings.cs:1209)

+1, have the same problem.
I suggest such a fix

        private List<IPAddress> FilterValidIPAddresses(List<IPAddress> ipAddresses)
        {
            List<IPAddress> validIpList = new List<IPAddress>();

            foreach (IPAddress address in ipAddresses)
            {
                try
                {
                    var sender = new System.Net.NetworkInformation.Ping();
                    var reply = sender.Send(address.ToString(), 5000);
                    if (reply.Status == IPStatus.Success)
                    {
                        validIpList.Add(address);
                    }
                }
                catch(Exception err)
                {
                    continue;
                }
            }
            return validIpList;
        }

in HostingServicesManager.cs…

Yeah would definitely want some fix or temporary hack for this. If I edit something manually, it gets restored with this warning:
ā€œThe package cache was invalidated and rebuilt because the following immutable asset(s) were unexpectedly altered: ā€

This bug is fixed in 1.19.11. Please see the fixed issue.

  • Fixed issue where hosting services filters ip addresses when entering playmode and no services are in use

Changelog | Addressables | 1.19.11 (unity3d.com)

Try update Addressables package to 1.19.11 version from Package Manager.

I updated it to 1.19.11. It does not happen on entering playmode anymore but it still throws the same error on every script compile.

I’m using the 2020.3.22f1 on Windows 7 SP1 with the same kind of errors.
I used both the Addressables: 1.18.19 and 1.19.11, with the same set of errors:
SocketException: The Socket operation succeeded.
SocketException: An attempt was made to access a Socket in a way that is forbidden by its access permissions.
Both error code 0 and 10013 from SocketError Enum (System.Net.Sockets) | Microsoft Learn.

Its related to the Socket 10013 error caused by the call System.Net.NetworkInformation.Ping.
It seems that ā€˜ping’ (ICMP) calls uses socket type SOCK_RAW, which have a different set of rules to be used (TCP/IP raw sockets - Win32 apps | Microsoft Learn). They are different from normal SOCK_STREAM/SOCK_DGRAM used in TCP/UDP connections. Those dont need admin privilege to bind.

I was able to reproduce the same kind of system errors using Python sockets
calling socket.socket(socket.AF_INET, socket.SOCK_RAW), giving the same error, but calling socket.socket(socket.AF_INET, socket.SOCK_STREAM) not.

The error is solved by calling it with elevated admin privileges, both on python or unity.

A simple temporary fix could be achieved with these steps:

  1. Have a backup of your project;
  2. Close the Unity Hub.exe (Dont forget the close in the system tray also);
  3. Find the Unity Hub.exe and right click into properties;
  4. Under Compatibility tab, check the box ā€œrun this program as administratorā€;

This will cause UAC screen to pop every time you open the unity hub, but once you open the unity editor through it, it will also inherit the same elevated privileges. Once the editor is opened this way, there’s no other SocketExceptions errors, at least for me.

This worked, thank you so much!

Wohoo… It worked for me…THank you so much :slight_smile:

1 Like