Author |
Share Topic Topic Search Topic Options
|
kdev
Groupie
Joined: 03-Jan-2013
Posts: 83
|
Post Options
Quote Reply
Topic: SignalR Posted: 04-Dec-2013 at 10:07am |
Worked thank you
|
|
sbelini
IdeaBlade
Joined: 13-Aug-2010
Location: Oakland
Posts: 786
|
Post Options
Quote Reply
Posted: 02-Dec-2013 at 5:39pm |
kdev,
You are using compositionContext, so you must specify what context you are using when you login:
var loginOptions = new LoginOptions(compositionContextName: "SignalRDefault");
var em = new EntityManager();
em.AuthenticationContext = Authenticator.Instance.Login(sessionKey, loginOptions);
|
|
kdev
Groupie
Joined: 03-Jan-2013
Posts: 83
|
Post Options
Quote Reply
Posted: 02-Dec-2013 at 6:41am |
|
|
sbelini
IdeaBlade
Joined: 13-Aug-2010
Location: Oakland
Posts: 786
|
Post Options
Quote Reply
Posted: 26-Nov-2013 at 9:55am |
kdev.
I'm checking what in Cocktail could be causing this behavior. I'll follow up shortly.
|
|
kdev
Groupie
Joined: 03-Jan-2013
Posts: 83
|
Post Options
Quote Reply
Posted: 25-Nov-2013 at 5:58am |
Any info/idea ?
|
|
kdev
Groupie
Joined: 03-Jan-2013
Posts: 83
|
Post Options
Quote Reply
Posted: 20-Nov-2013 at 6:45am |
Edit : repost of the post due to a delete by error
This SessionKey issue is making me crazy !
When I implement the Dummy Query in my application it doesn't work at all, I still get the "Relogin error" while it does in the test project.
I updated my first project test to implement IEntityManagerProvider<T> from Cocktail and it appears the relogin process doesn't happen completly when I use the manager coming from this service. To resume, prior to the Invoke code I don't get the same result depending of the way the entitymanager been created. Exemple :
// THIS VERSION WORKS var _em = new EntityManager(); var orders = await new EntityQuery<Order>().With(_em).With(QueryStrategy.DataSourceOnly).ExecuteAsync(); // THIS VERSION DOESN'T WORK var orders = await new EntityQuery<Order>().With(_entityManagerProvider.Manager).With(QueryStrategy.DataSourceOnly).ExecuteAsync();
|
|
|
kdev
Groupie
Joined: 03-Jan-2013
Posts: 83
|
Post Options
Quote Reply
Posted: 20-Nov-2013 at 2:38am |
I have a case where a ViewModel has no UnitOfwork or EntityManager at all, but I am doing SignalR call providing the Authenticationcontext.SessionKey as the signalr method will create entities with Audit information.
How, in this case, can I reconnect "something" with a dummy query without any EntityManager ? Is there a way to create a new EntityManager (with which parameters) which will allow the reconnection ?
|
|
kdev
Groupie
Joined: 03-Jan-2013
Posts: 83
|
Post Options
Quote Reply
Posted: 19-Nov-2013 at 9:48am |
Running the dummy query on the original EmtityManager works but I would like to be able to reconnect with another EntityManager.
why ? because I find to have to execute a query dummy before every call very annoying so I want to encapsulate the Invoke method frrom the SignalR.IHubProxy with this query call inside.
if I create a new EntityManager with the same ConnectionOption (cocktail) as the EntityManager I used to login in the application it doesn't work although they have the same sessionKey !
I noticed if I create an entityManager from the disconnected EntityManager it works (with new EntityManager(em)). but if I create it from an EntityManagerContext using the same values as the one in the disconnected em it doesn't.
var context = new EntityManagerContext( dataSourceExtension : disconnectedEm.DataSourceExtension, entityServiceOption: disconnectedEm.EntityServiceOption, compositionContextName: disconnectedEm.CompositionContext.Name, options: disconnectedEm.Options, serviceKey: disconnectedEm.ServiceKey);
I don't really understand why in some case it works and not in others. what is the use of the sessionkey if a newly entitymanager using the same sessionkey of the disconnected one doesn't do the job.
is it possible to achieve my scenario with cocktail ?
|
|
sbelini
IdeaBlade
Joined: 13-Aug-2010
Location: Oakland
Posts: 786
|
Post Options
Quote Reply
Posted: 30-Oct-2013 at 2:14pm |
Thanks for the additional information. That certainly helped.
The problem is that the same query executed a second time tend to run against the cache. To solve the problem set the query to explicitly run against the DataSource:
i.e.
await dummyQuery.With(QueryStrategy.DataSourceOnly).ExecuteAsync();
|
|
kdev
Groupie
Joined: 03-Jan-2013
Posts: 83
|
Post Options
Quote Reply
Posted: 30-Oct-2013 at 9:50am |
I should note it didn't throw the exception on the first timeout but the second.
Here is what I did :
- Click the button - Wait more than 1 minute - Click the button => Success - Wait more than 1 minute - Click the button => Fail
|
|
sbelini
IdeaBlade
Joined: 13-Aug-2010
Location: Oakland
Posts: 786
|
Post Options
Quote Reply
Posted: 30-Oct-2013 at 9:34am |
Interesting.
I'll check why it works here, but not there.
|
|
kdev
Groupie
Joined: 03-Jan-2013
Posts: 83
|
Post Options
Quote Reply
Posted: 30-Oct-2013 at 9:29am |
I tried your solution and it also has the issue :
|
|
sbelini
IdeaBlade
Joined: 13-Aug-2010
Location: Oakland
Posts: 786
|
Post Options
Quote Reply
Posted: 30-Oct-2013 at 9:13am |
kdev,
Executing a query fixes the issue - the client is silently logged back in using the information in the 'session bundle'. In this case, the sessionKey remains the same.
I tested calling a query before suggesting it to you and it worked fine. You can check my test solution here uploads/892/SignalR.zip. Note that since you stated this is a DevForce/SignalR issue, I removed Cocktail as it is not pertinent to the problem and only adds unnecessary complexity.
As for logging back in, you'd need the user to enter the credentials again. You are correct about not knowing if the session has timed out on the client side - specially because if a query/save is performed, the silent login occurs. Unless you want to implement some monitoring on the client that would require a manual login after a certain amount of time (time that would match the sessionTimeout in web.config), the easiest approach is to use the silent login by running a dummy query.
|
|
kdev
Groupie
Joined: 03-Jan-2013
Posts: 83
|
Post Options
Quote Reply
Posted: 30-Oct-2013 at 4:42am |
Hi,
Executing a query before a SignalR call indeed reconnects the client's EntityManager but doesn't fix the signalr issue as the SessionKey provided by the AuthtenticationContext never changes.
However, if the "query trick" worked, I find it very annoying to have to do a dummy query before every signalr call. I currently have many signalr calls and plan to have a lot more.
Below the updated project using a query prior to the signalr call
You said "you can log back in", how would you do that and based on which event/information ? Currently I have no way to know if the client is disconnected, the information on the AuthenticationContext always show "LoggedIn".
Regards
|
|
sbelini
IdeaBlade
Joined: 13-Aug-2010
Location: Oakland
Posts: 786
|
Post Options
Quote Reply
Posted: 29-Oct-2013 at 5:15pm |
kdev,
It turns out that this is not a bug. If after the session timeout the client performs a query or save, it will still work because DevForce silently logs the client back in because the “session bundle” contains enough information to do the login. You shouldn't expect it to happen on a SignalR call.
In this situation you can either log back in or perform an operation that would trigger the silent login.
|
|
sbelini
IdeaBlade
Joined: 13-Aug-2010
Location: Oakland
Posts: 786
|
Post Options
Quote Reply
Posted: 24-Oct-2013 at 12:41pm |
Thanks, kdev.
We will look into your sample and determine what the issue is.
|
|