Comments (14)
Perhaps unrelated, but are the grains are in a separate project and that project used the Microsoft.Orleans.Sdk
package? (if .Client
or .Server
is not used in that project.
from orleans.
This issue does not seem related to grain persistence. How is the client connecting to the cluster where the grain is hosted.
from orleans.
I'm running both the silo and the client locally for debugging. So, the client contacts a running instance of the silo on a localhost address.
Did a test and verified an older grain and it's working fine when the client calls _clusterClient.GetGrain<...>
so I can confirm the connection between the client and the silo is working.
from orleans.
Couple other simple things I've verified
- The grain interface inherits
IGrainWithStringKey
. - The grain class inherits
Grain
.
from orleans.
Yes, please confirm that you have the packages which @attilah mentioned on both the client, server, and grains/interfaces. Your grain/grain interface project should all reference Microsoft.Orleans.Sdk
. Your client should reference Microsoft.Orleans.Client
, and your server should reference Microsoft.Orleans.Server
.
from orleans.
There are 3 projects in the silo solution. One contains the interfaces and data models classes for request and response types. We call it Abstractions. The implementation of the grains are a different projects called Grains. Then there is the code gen project. All 3 projects have a reference to the Microsoft.Orleans.Sdk package version 7.2.4.
from orleans.
Yes, the client project has Microsoft.Orleans.Client 7.2.4 and the silo project has Microsoft.Orleans.Server 7.2.4.
from orleans.
@macfma01 is the client definitely connected to the silo before you call GetGrain
? If not, that may be the issue. How is the client's host being configured right now and when is the GetGrain
call being made in the client host's lifetime? If you can share some code snippets, that will be quite helpful
from orleans.
@macfma01 ah, wanted to confirm as that was what I missed...it is something I did not remember/changed since I was doing Orleans ;-)
from orleans.
I'm confident in the client/silo connection because I can activate other grains. Just not this newer one. The code for the client app is a vast ASP.NET app with calls out to Orleans spread around in the different classes. Each class that calls Orleans has an IClusterClient injected. We use both Guid and String based grains. We ask for a grain instance using GetGrain
For guid types
var grainRef = _clusterClient.GetGrain<IMyGrainInterface>(Guid.NewGuid());
For string string
var grainRef = _clusterClient.GetGrain<IMyGrainInterface>(Guid.NewGuid().ToString());
or some other relevant string key we're tracking.
I did a fresh build on the Orleans project and update the packages it produced on the client just verify that was up to date but it didn't make a difference. There seems to be something about the new grain that off. I just can't spot it yet.
Here are couple excerpts from Program.cs on the client in case that's relevant.
services.AddSingleton<ClusterClientHostedService>(); // orleans client host,
services.AddSingleton<IHostedService>(_ => _.GetRequiredService<ClusterClientHostedService>());
services.AddSingleton(_ => _.GetRequiredService<ClusterClientHostedService>()?.Client.Services.GetService<IClusterClient>());
Excepts from ClusterClientHostedService. I don't fully understand this class but I think it's designed to start up a new ClusterClient if it dies. I haven't delved into all this too deeply yet since I have grains that are working fine with all this it hasn't seemed like a likely cause.
public class ClusterClientHostedService : IHostedService
{
public IHost Client { get; }
public ClusterClientHostedService
{
var clientBuilder = new HostBuilder()
.ConfigureLogging(loggingBuilder =>
loggingBuilder.SetMinimumLevel(LogLevel.Information).AddProvider(loggerProvider))
.UseOrleansClient((context,siloBuilder) =>
{
siloBuilder.AddOutgoingGrainCallFilter<ClientGrainCallFilter>();
siloBuilder.AddActivityPropagation();
siloBuilder.Configure<ClusterOptions>(clusterOptions =>
{
clusterOptions.ClusterId = MyClusterInfo.GetClusterId(GetSiloEnvironment());
clusterOptions.ServiceId = MyClusterInfo.ServiceId;
}).ConfigureServices(services => { services.AddSingleton(DistributedContextPropagator.Current); });
if (GetSiloEnvironment() == "local")
{
siloBuilder.UseLocalhostClustering(
int.Parse((Environment.GetEnvironmentVariable("GATEWAYPORT"))),
MyClusterInfo.ServiceId,
MyClusterInfo.GetClusterId(GetSiloEnvironment())
);
}
else
{
siloBuilder.UseDynamoDBClustering(dynamoDbGatewayOptions =>
{
dynamoDbGatewayOptions.Service = AwsHelpers.GetAwsRegion();
dynamoDbGatewayOptions.TableName = ErsClusterInfo.MembershipTableName;
dynamoDbGatewayOptions.UpdateIfExists = false;
});
}
});
Client = clientBuilder.Build();
}
public async Task StartAsync(CancellationToken cancellationToken)
{
try
{
while (true)
{
try
{
if (cancellationToken.IsCancellationRequested)
{
throw new OperationCanceledException("Orleans cluster connection cancelled");
}
await Client.StartAsync(cancellationToken);
return;
}
catch (Exception exception)
{
_logger.LogWarning(
exception,
"Failed to connect to Orleans cluster on attempt {attempt} of {maxAttempts}.", attempt, maxAttempts);
if (++attempt <= maxAttempts)
{
await Task.Delay(delay, cancellationToken);
}
else
{
throw new Exception("Unable to connect to Orleans cluster");
}
}
}
}
catch (Exception exception)
{
}
}
from orleans.
I'm pretty sure it's a bug in the cluster client class. I'll double check everything and update this issue tomorrow. The env variable isn't returning local as expected
if (GetSiloEnvironment() == "local")
I might be getting the local interfaces and trying to grains from another dev silo where they haven't been deployed yet.
from orleans.
Does the issue resolve itself after the client has been connected to the cluster for some time?
from orleans.
I've confirmed this was a misconfiguration in our launch settings. The client wasn't using the right settings for local connections as I had thought 😳 Since some of the calls were working I mistakenly assumed it was good but the client was talking to another silo on our dev environment (I think). The grain I was getting an error on is loading up fine now. So, there was no Orleans issue at all. Thanks for your questions and suggestions for things to check. That led me to the root cause.
from orleans.
Glad to see that you got it fixed!
from orleans.
Related Issues (20)
- OrleansQuery not exists HOT 7
- ObjectDisposedException at Orleans.Runtime.Messaging.MessageCenter.ReceiveMessage HOT 3
- [bug/feature request] default codec for collections HOT 1
- AWS Kinesis Streaming
- Orleans membership table is not cleared properly from obsolete silos
- `UseUnixSocketConnection` not working
- Ability to skip time to trigger reminders for testing (using TimeProvider)
- Errors on kubernetes hosting with different cluster ids? HOT 1
- How do I place grain according to the silo category?
- Bug: Exclude inaccessible interface methods from codegen HOT 3
- `IGrainReferenceActivatorProvider` exception with interfaces written in F# HOT 1
- [Question] Orlean grain does not allow concurrent read HOT 2
- Typo in silo start log HOT 1
- Awaiting this.AsReference call causes deadlock in Orleans 7+ HOT 5
- [Question] How to connect Orleans Client to Orleans Server in Docker? HOT 3
- Issues with streams during rolling deploy (Orleans.Streams.QueueCacheMissException)
- In Orleans 8.1.0, after 90 seconds, the Silo and Gateway ports will change from the status LISTEN to CLOSED, which prevents further connections.
- Cannot serialize type inheriting from Dictionary HOT 3
- Pulling agents don't work properly with MemoryStreams on multiple silos
- Bug: Invalid code generated for interface with explicit implementations
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from orleans.