Skip to content

Commit 9a5da81

Browse files
authored
Merge pull request #180 from kuzzleio/fix-websocket-port
use 7512 port by default for both websocket and socketio
2 parents 601d67d + cb0e775 commit 9a5da81

File tree

4 files changed

+13
-26
lines changed

4 files changed

+13
-26
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ The complete SDK documentation is available [here](http://kuzzleio.github.io/sdk
3333
The SDK Javascript implements two network protocols: raw WebSocket, and [Socket.IO](http://socket.io/)
3434
The main reason behind this is that while Socket.IO offers better compatibility with older web browsers, our raw WebSocket implementation is about 20% faster
3535

36-
For this reason, there is a slight difference with the [generic SDK documentation](http://kuzzleio.github.io/sdk-documentation): instead of 1 available `port` option, there are actually a `wsPort` and a `ioPort` options.
37-
These options are defaulted to Kuzzle default protocol plugins.
38-
3936
What protocol is used when you connect to Kuzzle depends on multiple factors:
4037

4138
#### NodeJS
@@ -141,7 +138,7 @@ kuzzle
141138

142139
## Migrating from SDK v1.x
143140

144-
* Kuzzle constructor has been changed. Instead of an URL, you have to provide a resolvable server name, or an IP address. If you need to specify a port different than the provided default values, you can do so using these two new options: `wsPort` (WebSocket port) and `ioPort` (Socket.IO port)
141+
* Kuzzle constructor has been changed. Instead of an URL, you have to provide a resolvable server name, or an IP address. If you need to specify a port different than the provided default value, you can do so using the `port` option.
145142

146143
## License
147144

src/Kuzzle.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,8 @@ function Kuzzle (host, options, cb) {
113113
writable: true,
114114
enumerable: true
115115
},
116-
wsPort: {
117-
value: (options && typeof options.wsPort === 'number') ? options.wsPort : 7513,
118-
enumerable: true,
119-
writable: true
120-
},
121-
ioPort: {
122-
value: (options && typeof options.ioPort === 'number') ? options.ioPort : 7512,
116+
port: {
117+
value: (options && typeof options.port === 'number') ? options.port : 7512,
123118
enumerable: true,
124119
writable: true
125120
},
@@ -322,7 +317,7 @@ Kuzzle.prototype.connect = function () {
322317
self.disconnect();
323318
}
324319

325-
self.network = networkWrapper(self.host, self.wsPort, self.ioPort, self.sslConnection);
320+
self.network = networkWrapper(self.host, self.port, self.sslConnection);
326321

327322
if (['initializing', 'ready', 'disconnected', 'error', 'offline'].indexOf(this.state) === -1) {
328323
if (self.connectCB) {

src/networkWrapper/index.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
/**
22
*
33
* @param host
4-
* @param wsPort
5-
* @param ioPort
4+
* @param port
65
* @param sslConnection
76
* @returns {Object} tnstantiated WebSocket/Socket.IO object
87
*/
98

10-
function network(host, wsPort, ioPort, sslConnection) {
9+
function network(host, port, sslConnection) {
1110
// Web browser / NodeJS websocket handling
1211
if (typeof window !== 'undefined') {
1312
// use native websockets if the browser supports it
1413
if (typeof WebSocket !== 'undefined') {
15-
return new (require('./wrappers/websocket'))(host, wsPort, sslConnection);
14+
return new (require('./wrappers/websocket'))(host, port, sslConnection);
1615
}
1716
// otherwise fallback to socket.io, if available
1817
else if (window.io) {
19-
return new (require('./wrappers/socketio'))(host, ioPort, sslConnection);
18+
return new (require('./wrappers/socketio'))(host, port, sslConnection);
2019
}
2120

2221
throw new Error('Aborting: no websocket support detected and no socket.io library loaded either.');
2322
}
2423

25-
return new (require('./wrappers/websocket'))(host, wsPort, sslConnection);
24+
return new (require('./wrappers/websocket'))(host, port, sslConnection);
2625
}
2726

2827
module.exports = network;

test/kuzzle/constructor.test.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ describe('Kuzzle constructor', () => {
7070
should(kuzzle).have.propertyWithDescriptor('reconnectionDelay', { enumerable: true, writable: false, configurable: false });
7171
should(kuzzle).have.propertyWithDescriptor('jwtToken', { enumerable: true, writable: true, configurable: false });
7272
should(kuzzle).have.propertyWithDescriptor('offlineQueueLoader', { enumerable: true, writable: true, configurable: false });
73-
should(kuzzle).have.propertyWithDescriptor('wsPort', { enumerable: true, writable: true, configurable: false });
74-
should(kuzzle).have.propertyWithDescriptor('ioPort', { enumerable: true, writable: true, configurable: false });
73+
should(kuzzle).have.propertyWithDescriptor('port', { enumerable: true, writable: true, configurable: false });
7574
should(kuzzle).have.propertyWithDescriptor('sslConnection', { enumerable: true, writable: false, configurable: false });
7675
});
7776

@@ -89,8 +88,7 @@ describe('Kuzzle constructor', () => {
8988
should(kuzzle.replayInterval).be.exactly(10);
9089
should(kuzzle.reconnectionDelay).be.exactly(1000);
9190
should(kuzzle.defaultIndex).be.undefined();
92-
should(kuzzle.wsPort).be.exactly(7513);
93-
should(kuzzle.ioPort).be.exactly(7512);
91+
should(kuzzle.port).be.exactly(7512);
9492
should(kuzzle.sslConnection).be.false();
9593
});
9694

@@ -108,8 +106,7 @@ describe('Kuzzle constructor', () => {
108106
replayInterval: 99999,
109107
reconnectionDelay: 666,
110108
defaultIndex: 'foobar',
111-
wsPort: 1234,
112-
ioPort: 4567,
109+
port: 1234,
113110
sslConnection: true
114111
},
115112
kuzzle = new Kuzzle('nowhere', options);
@@ -125,8 +122,7 @@ describe('Kuzzle constructor', () => {
125122
should(kuzzle.metadata).be.an.Object().and.match(options.metadata);
126123
should(kuzzle.replayInterval).be.exactly(options.replayInterval);
127124
should(kuzzle.reconnectionDelay).be.exactly(options.reconnectionDelay);
128-
should(kuzzle.wsPort).be.exactly(options.wsPort);
129-
should(kuzzle.ioPort).be.exactly(options.ioPort);
125+
should(kuzzle.port).be.exactly(options.port);
130126
should(kuzzle.sslConnection).be.exactly(options.sslConnection);
131127
});
132128

0 commit comments

Comments
 (0)