Fix websocket URL when specifying port in the config (#6748)

Этот коммит содержится в:
Joram Wilander
2017-06-26 11:39:24 -04:00
коммит произвёл Christopher Speller
родитель 23ccfc845c
Коммит e285839ee1

Просмотреть файл

@@ -31,6 +31,7 @@ const getState = store.getState;
import {batchActions} from 'redux-batched-actions'; import {batchActions} from 'redux-batched-actions';
import {Client4} from 'mattermost-redux/client'; import {Client4} from 'mattermost-redux/client';
import {getSiteURL} from 'utils/url.jsx';
import * as TeamActions from 'mattermost-redux/actions/teams'; import * as TeamActions from 'mattermost-redux/actions/teams';
import {viewChannel, getChannelAndMyMember, getChannelStats} from 'mattermost-redux/actions/channels'; import {viewChannel, getChannelAndMyMember, getChannelStats} from 'mattermost-redux/actions/channels';
@@ -46,7 +47,7 @@ export function initialize() {
return; return;
} }
let connUrl = Client4.getWebSocketUrl(); let connUrl = getSiteURL();
// replace the protocol with a websocket one // replace the protocol with a websocket one
if (connUrl.startsWith('https:')) { if (connUrl.startsWith('https:')) {
@@ -56,7 +57,7 @@ export function initialize() {
} }
// append a port number if one isn't already specified // append a port number if one isn't already specified
if (!(/:\d+/).test(connUrl)) { if (!(/:\d+$/).test(connUrl)) {
if (connUrl.startsWith('wss:')) { if (connUrl.startsWith('wss:')) {
connUrl += ':' + global.window.mm_config.WebsocketSecurePort; connUrl += ':' + global.window.mm_config.WebsocketSecurePort;
} else { } else {
@@ -64,6 +65,8 @@ export function initialize() {
} }
} }
connUrl += Client4.getUrlVersion() + '/websocket';
WebSocketClient.setEventCallback(handleEvent); WebSocketClient.setEventCallback(handleEvent);
WebSocketClient.setFirstConnectCallback(handleFirstConnect); WebSocketClient.setFirstConnectCallback(handleFirstConnect);
WebSocketClient.setReconnectCallback(() => reconnect(false)); WebSocketClient.setReconnectCallback(() => reconnect(false));