File tree 2 files changed +5
-4
lines changed
2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ import { StreamBuilder } from '../shared'
2
2
3
3
import net from 'net'
4
4
import _debug from 'debug'
5
- import { Duplex } from 'readable-stream'
6
5
7
6
const debug = _debug ( 'mqttjs:tcp' )
8
7
/*
Original file line number Diff line number Diff line change @@ -28,16 +28,15 @@ function buildUrl(opts: IClientOptions, client: MqttClient) {
28
28
29
29
function setDefaultOpts ( opts : IClientOptions ) {
30
30
const options = opts
31
- if ( ! opts . hostname ) {
32
- options . hostname = 'localhost'
33
- }
31
+
34
32
if ( ! opts . port ) {
35
33
if ( opts . protocol === 'wss' ) {
36
34
options . port = 443
37
35
} else {
38
36
options . port = 80
39
37
}
40
38
}
39
+
41
40
if ( ! opts . path ) {
42
41
options . path = '/'
43
42
}
@@ -141,6 +140,9 @@ function createBrowserWebSocket(client: MqttClient, opts: IClientOptions) {
141
140
const streamBuilder : StreamBuilder = ( client , opts ) => {
142
141
debug ( 'streamBuilder' )
143
142
const options = setDefaultOpts ( opts )
143
+
144
+ options . hostname = options . hostname || options . host || 'localhost'
145
+
144
146
const url = buildUrl ( options , client )
145
147
const socket = createWebSocket ( client , url , options )
146
148
const webSocketStream = Ws . createWebSocketStream (
You can’t perform that action at this time.
0 commit comments