gwendall / meteor-remote-ddp

Get your Meteor client point to any DDP server
10 stars 5 forks source link

Remote User Login Works - Reload disconnects user #1

Open gerwinbrunner opened 9 years ago

gerwinbrunner commented 9 years ago

Hi,

I created a simple meteor application that uses the remote-ddp package to connect to a meteor server (System A) with a full app.

I want to use the users of the remote users of the system A in this new app.

I added following code in a file the client/lib folder of the new app the following code: (points to server A)

RemoteDDP("http://192.168.7.112:3000");

I'm now able to log into the new app with an existing user. Hurray! But then I reload the page, I get the following message in the browsers console:

Error logging in with token: Error: You've been logged out by the server. Please log in again. [403]

When I took a closer look at the ddp messages, I saw that the login message was sent to the new server instead of server A after the reload.

Do you have a clue what might cause this behaviour and how to fix it?

Cheers, Gerwin

gwendall commented 9 years ago

Probably due to the fact that Accounts calls the login method before remote-ddp updates its connection. I will have a look into it when I have time.

gerwinbrunner commented 9 years ago

That would be really awesome. Is there some way I can help you with this?

gwendall wrote:

Probably due to the fact that Accounts calls the |login| method before |remote-ddp| updates its connection. I will have a look into it when I have time.

— Reply to this email directly or view it on GitHub https://github.com/gwendall/meteor-remote-ddp/issues/1#issuecomment-89632187.

gerwinbrunner commented 9 years ago

@gwendall where would you recommend to put the RemoteDDP call? Which file?

BudgieInWA commented 9 years ago

By looking at the DDP messages, I can confirm that the resume request is sent to the natural DDP connection (DDP_DEFAULT_CONNECTION_URL) instead of the that specified in RemoteDDP.

The resume request looks like this:

{"msg":"method","method":"login","params":[{"resume":"fkc1ZFUYqmfvN4kkAzm0RJQwkPvgRsIUaFSbYXG8wYu"}],"id":"1"}
rafaelcorreiapoli commented 9 years ago

Do we have any workaround on this ?

BudgieInWA commented 9 years ago

I managed to get it working well enough for myself (and I forgot to come back here). My approach is to use a private feature of the Accounts package to tell it to connect to the desired URL, then use the connection that it creates for everything else. As you might guess, it's quite brittle and the API is different. It's available at BudgieInWA/meteor-remote-ddp

rafaelcorreiapoli commented 9 years ago

Thanks man!! it worked!

rafaelcorreiapoli commented 8 years ago

Hi, how can I make it avaiable everywhere? I need to install this on a lot of projects, do you putting it on atmosphere? @BudgieInWA

BudgieInWA commented 8 years ago

As my version is so different from this one, I have published it at https://atmospherejs.com/budgie/remote-ddp. Further discussion about it should take place at my fork. Let me know how it goes.