Closed RockNHawk closed 2 years ago
I have create two Unit Test Project, one is .NET Core another is .NET Framework, the setup code is all the same, the .NET Core UnitTest works well, but .NET Framework fails with the same error as the above.
Microsoft.Orleans.Networking: Information: Closing connection with remote endpoint 127.0.0.1:52774
Microsoft.Orleans.Networking: Information: Connection Local: 127.0.0.1:30000, Remote: 127.0.0.1:52774, ConnectionId: 0HLTL8QQET84J terminated
Exception thrown: 'System.Net.Sockets.SocketException' in System.Net.Primitives.dll
An exception of type 'System.Net.Sockets.SocketException' occurred in System.Net.Primitives.dll and wasn't handled before a managed/native boundary
The attempted operation is not supported for the type of object referenced.
StackTrace:
at System.Net.IPAddress.get_ScopeId()
I have tested, this code cause the Exception:
var IP = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1000);
IP.Address.ScopeId.ToString();
System.Net.Sockets.SocketException : The attempted operation is not supported for the type of object referenced
at System.Net.IPAddress.get_ScopeId()
ScopeID is an IPv6 specific field. You have an IPv4 address. Therefore, an exception is raised. InterNetwork in this case means IPv4.
https://docs.microsoft.com/en-us/dotnet/api/system.net.ipaddress.scopeid?view=netframework-4.8
Hi, I've debug the CallStack
from the IPAddress.ScopeId
, a Log of the Connection
object cause the IPAddress.ScopeId
call.
@benjaminpetit @sergeybykov
ConnectionListener.cs
private async Task RunConnectionAsync(Connection connection)
{
await Task.Yield();
using (this.BeginConnectionScope(connection))
{
try
{
Task task = connection.Run();
this.connections.TryAdd(connection, task);
await task;
this.trace.LogInformation("Connection {@Connection} terminated", (object) connection);
}
catch (Exception ex)
{
this.trace.LogInformation(ex, "Connection {@Connection} terminated with an exception", (object) connection);
}
finally
{
Task task;
this.connections.TryRemove(connection, out task);
}
}
}
Thanks for debugging, @RockNHawk! Could you submit a PR to fix this?
I think the easiest workaround for this is to log the connection as a string instead of logging it as a rich object (eg, by removing the '@' prefix in the logging code you pasted - and potentially in other, similar locations). The root issue seems to be in Serilog / System.Net, depending on how you look at it. Arguably, some objects just should not be passed to logging with the '@' specifier.
Thanks for debugging, @RockNHawk! Could you submit a PR to fix this?
I think the easiest workaround for this is to log the connection as a string instead of logging it as a rich object (eg, by removing the '@' prefix in the logging code you pasted - and potentially in other, similar locations). The root issue seems to be in Serilog / System.Net, depending on how you look at it. Arguably, some objects just should not be passed to logging with the '@' specifier.
Thaky for you reply, I'm still debugging, Unfortunately this is not the root cause of the Client is rejecting
error, seems an internal bug in Orleans.
After I update the Orleans Silo
project from Nuget 3.0.2 version to git source code master version c11be30
, .NET Framework with ASP.NET Client works well, but .NET Framework UnitTest not work.
Hi, I for forked from Sample Blazor proejct it works well and I add a
.NET Framework
web project with the same confuguration.I if Client is .NET Core Web project,
ClusterClient.Connect()
works well, but if Client run on.NET Framework
Web project, got this error:and the
Silo
Console show the log:The detail Silo log:
} terminated
I have searched but no related issue,How can I reslove this issue?