Closed chogarcia closed 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
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?
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
?
Any help with this will be much appreciated
What do you have in settings.js?
if you go to sd.domain.com/settings.js
what does it produce?
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
Which version of SD are you using?
SwampDragon 0.4.2.2
a bit weird because get_host()
in settings_provider.py
gets the right DRAGON_URL
value, which is https://sd.domain.com/
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')
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?