Default to using port 8883 when using TLS.

pull/181/merge
Roger A. Light 10 years ago
parent 030a21786d
commit 99ea5cab7c

@ -46,6 +46,7 @@ Client:
- Add --retained-only to mosquitto_sub to exit after receiving all retained
messages.
- Connections now default to using MQTT v3.1.1.
- Default to using port 8883 when using TLS.
1.4.7 - 20151221

@ -37,7 +37,7 @@ static int client_config_line_proc(struct mosq_config *cfg, int pub_or_sub, int
void init_config(struct mosq_config *cfg)
{
memset(cfg, 0, sizeof(*cfg));
cfg->port = 1883;
cfg->port = -1;
cfg->max_inflight = 20;
cfg->keepalive = 60;
cfg->clean_session = true;
@ -428,6 +428,7 @@ int client_config_line_proc(struct mosq_config *cfg, int pub_or_sub, int argc, c
if(!strncasecmp(url, "mqtt://", 7)) {
url += 7;
cfg->port = 1883;
} else if(!strncasecmp(url, "mqtts://", 8)) {
url += 8;
cfg->port = 8883;
@ -831,15 +832,32 @@ int client_connect(struct mosquitto *mosq, struct mosq_config *cfg)
{
char err[1024];
int rc;
int port;
#ifdef WITH_TLS
if(cfg->port < 0){
if(cfg->cafile || cfg->capath
#ifdef WITH_TLS_PSK
|| cfg->psk
#endif
){
port = 8883;
}else{
port = 1883;
}
}else{
port = cfg->port;
}
#endif
#ifdef WITH_SRV
if(cfg->use_srv){
rc = mosquitto_connect_srv(mosq, cfg->host, cfg->keepalive, cfg->bind_address);
}else{
rc = mosquitto_connect_bind(mosq, cfg->host, cfg->port, cfg->keepalive, cfg->bind_address);
rc = mosquitto_connect_bind(mosq, cfg->host, port, cfg->keepalive, cfg->bind_address);
}
#else
rc = mosquitto_connect_bind(mosq, cfg->host, cfg->port, cfg->keepalive, cfg->bind_address);
rc = mosquitto_connect_bind(mosq, cfg->host, port, cfg->keepalive, cfg->bind_address);
#endif
if(rc>0){
if(!cfg->quiet){

@ -238,9 +238,12 @@
<term><option>-L</option></term>
<term><option>--url</option></term>
<listitem>
<para>Specify specify user, password, hostname, port and topic at once as a URL.
The URL must be in the form:
mqtt(s)://[username[:password]@]host[:port]/topic</para>
<para>Specify specify user, password, hostname, port and
topic at once as a URL. The URL must be in the form:
mqtt(s)://[username[:password]@]host[:port]/topic</para>
<para>If the scheme is mqtt:// then the port defaults to
1883. If the scheme is mqtts:// then the port defaults
to 8883.</para>
</listitem>
</varlistentry>
<varlistentry>
@ -268,7 +271,9 @@
<term><option>-p</option></term>
<term><option>--port</option></term>
<listitem>
<para>Connect to the port specified instead of the default 1883 for plain MQTT and 8883 for MQTT over TLS.</para>
<para>Connect to the port specified. If not given, the
default of 1883 for plain MQTT or 8883 for MQTT over
TLS will be used.</para>
</listitem>
</varlistentry>
<varlistentry>

@ -267,9 +267,12 @@
<term><option>-L</option></term>
<term><option>--url</option></term>
<listitem>
<para>Specify specify user, password, hostname, port and topic at once as a URL.
The URL must be in the form:
mqtt(s)://[username[:password]@]host[:port]/topic</para>
<para>Specify specify user, password, hostname, port and
topic at once as a URL. The URL must be in the form:
mqtt(s)://[username[:password]@]host[:port]/topic</para>
<para>If the scheme is mqtt:// then the port defaults to
1883. If the scheme is mqtts:// then the port defaults
to 8883.</para>
</listitem>
</varlistentry>
<varlistentry>
@ -286,7 +289,9 @@
<term><option>-p</option></term>
<term><option>--port</option></term>
<listitem>
<para>Connect to the port specified instead of the default 1883 for plain MQTT and 8883 for MQTT over TLS.</para>
<para>Connect to the port specified. If not given, the
default of 1883 for plain MQTT or 8883 for MQTT over
TLS will be used.</para>
</listitem>
</varlistentry>
<varlistentry>

Loading…
Cancel
Save