Skip to content
Snippets Groups Projects
Commit 3557def8 authored by Mathis Neumann's avatar Mathis Neumann
Browse files

temporarily disable websocket reconnects for production (heroku) deployment

parent 0e8fafc0
No related branches found
No related tags found
No related merge requests found
import Ember from 'ember';
import RESTAdapter from 'ember-data/adapters/rest';
import FixtureAdapter from 'ember-data-fixture-adapter';
import ENV from 'iobserve-ui/config/environment';
export default RESTAdapter.extend({
host: 'http://localhost:8080', // TODO: replace with live url
host: ENV.APP.API_ROOT,
namespace: 'v1',
session: Ember.inject.service()
});
\ No newline at end of file
import Ember from 'ember';
import ENV from 'iobserve-ui/config/environment';
export default Ember.Service.extend({
changelogQueue: Ember.inject.service(),
......@@ -11,7 +12,7 @@ export default Ember.Service.extend({
this.set('shouldClose', false);
this.debug('setting up websocket', systemId);
const socket = new WebSocket(`ws://localhost:8080/v1/changelogstream/${systemId}`); // TODO: from environment!
const socket = new WebSocket(`${ENV.APP.WEBSOCKET_ROOT}/v1/changelogstream/${systemId}`);
this.set('socket', socket);
socket.onopen = this.get('events.onOpen').bind(this);
......@@ -19,15 +20,17 @@ export default Ember.Service.extend({
socket.onmessage = this.get('events.onMessage').bind(this);
// automatically reconnect
socket.onclose = () => {
if(!this.get('shouldClose')) {
this.debug('connection lost, reconnecting!');
this.set('reconnectionTimeout', setTimeout(() => {
this.connect(systemId);
this.set('reconnectionTimeout', null);
}, 500));
}
};
if(ENV.APP.WEBSOCKET_RECONNECT) {
socket.onclose = () => {
if(!this.get('shouldClose')) {
this.debug('connection lost, reconnecting!');
this.set('reconnectionTimeout', setTimeout(() => {
this.connect(systemId);
this.set('reconnectionTimeout', null);
}, 500));
}
};
}
// close socket connection when the user closes the window/tab or nagivates to a different website
window.onbeforeunload = this.get('disconnect').bind(this);
......
......@@ -17,6 +17,9 @@ module.exports = function(environment) {
APP: {
// Here you can pass flags/options to your application instance
// when it is created
API_ROOT: 'http://iobserve-api.herokuapp.com',
WEBSOCKET_ROOT: 'ws://iobserve-api.herokuapp.com',
WEBSOCKET_RECONNECT: false // not running on heroku/jetty-runner
}
};
......@@ -27,6 +30,10 @@ module.exports = function(environment) {
// ENV.APP.LOG_TRANSITIONS = true;
// ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
// ENV.APP.LOG_VIEW_LOOKUPS = true;
ENV.APP.API_ROOT = 'http://localhost:8080';
ENV.APP.WEBSOCKET_ROOT = 'ws://localhost:8080';
ENV.APP.WEBSOCKET_RECONNECT = true;
}
if (environment === 'test') {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment