hagsteel / swampdragon

swampdragon
Other
557 stars 74 forks source link

SwampDragon with Ionic Framework #165

Closed chogarcia closed 8 years ago

chogarcia commented 8 years ago

I am testing SwampDragon with Ionic Framework and it seems to be working really good. The only concern I have is including the url to settings.js directly in the app.

any other different approaches you have in mind?

hagsteel commented 8 years ago

In what sense do you worry about it? The settings are exposed to the client so you shouldn't put anything sensitive in there, but I get the feeling that you don't and I'm just missing the point

chogarcia commented 8 years ago

Haven't thought the possibility of SwampDragon for a mobile app and I wanted to know opinions from others that is all.

My concern is related to deployments. Every time you deploy and restart SwampDragon process to apply python changes the connection is lost and a JavaScript error is thrown. I would like to know how to apply a fallback to other cluster if fails.

This makes me think that probably is better to define this window settings directly in AngularJS and if there is no connection fallback to other settings?

chogarcia commented 8 years ago

settings.js in production is returning:

window.swampdragon_settings = {'endpoint': '/data'};
window.swampdragon_host = "http://127.0.0.1:9999";

and my live settings.py are:

DRAGON_URL = 'https://sd.domain.com/'
SWAMP_DRAGON_HOST = 'https://sd.domain.com'
SWAMP_DRAGON_PORT = '9000'

and nginx is:

upstream swampdragon {
    server 127.0.0.1:9000;
    server 127.0.0.1:9001;
}
[...]
server {
    listen       80;
    server_name sd.domain.com;

    # WebSocket.
    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_set_header Host $http_host;
        proxy_pass http://swampdragon;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

so I am not sure how to set a websocket server like: var dataStream = $websocket('wss://sd.domain.com/data');

SwampDragon seems to not pick up DRAGON_URL in settings.py?

chogarcia commented 8 years ago

Any help with this will be much appreciated

hagsteel commented 8 years ago

What do you have in settings.js? if you go to sd.domain.com/settings.js what does it produce?

chogarcia commented 8 years ago

settings.js in production is returning:

window.swampdragon_settings = {'endpoint': '/data'};
window.swampdragon_host = "http://127.0.0.1:9999";

I had no luck trying to change that swampdragon_host

hagsteel commented 8 years ago

Which version of SD are you using?

chogarcia commented 8 years ago

SwampDragon 0.4.2.2

chogarcia commented 8 years ago

a bit weird because get_host() in settings_provider.py gets the right DRAGON_URL value, which is https://sd.domain.com/

chogarcia commented 8 years ago

I got it working.

Basically this from the docs: SWAMP_DRAGON_CONNECTION = ('swampdragon.connections.sockjs_connection.DjangoSubscriberConnection', '/data')

is not working but this:

SWAMP_DRAGON_CONNECTION = ('swampdragon_auth.socketconnection.HttpDataConnection', '/data')