Browse Source

update mq host specification

Anish Mukherjee 2 years ago
parent
commit
92327ebd2f

+ 1 - 2
compose/docker-compose-emqx.yml

@@ -25,9 +25,8 @@ services:
       DISPLAY_KEYS: "on"
       DISPLAY_KEYS: "on"
       DATABASE: "sqlite"
       DATABASE: "sqlite"
       NODE_ID: "netmaker-server-1"
       NODE_ID: "netmaker-server-1"
-      MQ_HOST: "mq"
+      MQ_HOST: "ws://mq:8083/mqtt"
       MQ_PORT: "443"      
       MQ_PORT: "443"      
-      MQ_SERVER_PORT: "8083"
       STUN_PORT: "3478"      
       STUN_PORT: "3478"      
       VERBOSITY: "1"
       VERBOSITY: "1"
       MQ_PASSWORD: "REPLACE_MQ_PASSWORD"
       MQ_PASSWORD: "REPLACE_MQ_PASSWORD"

+ 1 - 2
compose/docker-compose.ee.yml

@@ -25,9 +25,8 @@ services:
       DISPLAY_KEYS: "on"
       DISPLAY_KEYS: "on"
       DATABASE: "sqlite"
       DATABASE: "sqlite"
       NODE_ID: "netmaker-server-1"
       NODE_ID: "netmaker-server-1"
-      MQ_HOST: "mq"
+      MQ_HOST: "ws://mq:8083/mqtt"
       MQ_PORT: "443"
       MQ_PORT: "443"
-      MQ_SERVER_PORT: "8083"
       MQ_PASSWORD: "REPLACE_MQ_PASSWORD"
       MQ_PASSWORD: "REPLACE_MQ_PASSWORD"
       MQ_USERNAME: "REPLACE_MQ_USERNAME"
       MQ_USERNAME: "REPLACE_MQ_USERNAME"
       MQ_PASSWORD: "REPLACE_MQ_PASSWORD"
       MQ_PASSWORD: "REPLACE_MQ_PASSWORD"

+ 1 - 2
compose/docker-compose.reference.yml

@@ -26,9 +26,8 @@ services:
       DISPLAY_KEYS: "on" # Show keys permanently in UI (until deleted) as opposed to 1-time display.
       DISPLAY_KEYS: "on" # Show keys permanently in UI (until deleted) as opposed to 1-time display.
       DATABASE: "sqlite" # Database to use - sqlite, postgres, or rqlite
       DATABASE: "sqlite" # Database to use - sqlite, postgres, or rqlite
       NODE_ID: "netmaker-server-1" # used for HA - identifies this server vs other servers
       NODE_ID: "netmaker-server-1" # used for HA - identifies this server vs other servers
-      MQ_HOST: "mq"  # the address of the mq server. If running from docker compose it will be "mq". Otherwise, need to input address. If using "host networking", it will find and detect the IP of the mq container.
+      MQ_HOST: ""ws://mq:1883""  # the address of the mq server. If running from docker compose it will be "mq". Otherwise, need to input address. If using "host networking", it will find and detect the IP of the mq container.
       MQ_PORT: "443" # the reachable port of MQ - change if external MQ port changes (port on proxy, not necessarily the one exposed in docker-compose)
       MQ_PORT: "443" # the reachable port of MQ - change if external MQ port changes (port on proxy, not necessarily the one exposed in docker-compose)
-      MQ_SERVER_PORT: "1883" # the reachable port of MQ by the server - change if internal MQ port changes (or use external port if MQ is not on the same machine)
       MQ_USERNAME: "REPLACE_MQ_USERNAME" # the username to set for MQ access
       MQ_USERNAME: "REPLACE_MQ_USERNAME" # the username to set for MQ access
       MQ_PASSWORD: "REPLACE_MQ_PASSWORD" # the password to set for MQ access
       MQ_PASSWORD: "REPLACE_MQ_PASSWORD" # the password to set for MQ access
       STUN_PORT: "3478" # the reachable port of STUN on the server
       STUN_PORT: "3478" # the reachable port of STUN on the server

+ 1 - 2
compose/docker-compose.yml

@@ -23,9 +23,8 @@ services:
       DISPLAY_KEYS: "on"
       DISPLAY_KEYS: "on"
       DATABASE: "sqlite"
       DATABASE: "sqlite"
       NODE_ID: "netmaker-server-1"
       NODE_ID: "netmaker-server-1"
-      MQ_HOST: "mq"
+      MQ_HOST: "ws://mq:1883"
       MQ_PORT: "443"      
       MQ_PORT: "443"      
-      MQ_SERVER_PORT: "1883"
       STUN_PORT: "3478"      
       STUN_PORT: "3478"      
       VERBOSITY: "1"
       VERBOSITY: "1"
       MQ_PASSWORD: "REPLACE_MQ_PASSWORD"
       MQ_PASSWORD: "REPLACE_MQ_PASSWORD"

+ 2 - 22
servercfg/serverconf.go

@@ -245,19 +245,10 @@ func GetMessageQueueEndpoint() (string, bool) {
 		host = os.Getenv("MQ_HOST")
 		host = os.Getenv("MQ_HOST")
 	} else if config.Config.Server.MQHOST != "" {
 	} else if config.Config.Server.MQHOST != "" {
 		host = config.Config.Server.MQHOST
 		host = config.Config.Server.MQHOST
-	}
-	secure := strings.Contains(host, "wss") || strings.Contains(host, "ssl")
-	if secure {
-		host = "wss://" + host
 	} else {
 	} else {
-		host = "ws://" + host
-	}
-	host += ":" + GetMQServerPort()
-	// websocket listen endpoint for EMQX broker is ws://host:port/mqtt
-	if GetBrokerType() == EmqxBrokerType {
-		host += "/mqtt"
+		host += ":1883" // default
 	}
 	}
-	return host, secure
+	return host, strings.Contains(host, "wss") || strings.Contains(host, "ssl")
 }
 }
 
 
 // GetBrokerType - returns the type of MQ broker
 // GetBrokerType - returns the type of MQ broker
@@ -599,17 +590,6 @@ func GetAzureTenant() string {
 	return azureTenant
 	return azureTenant
 }
 }
 
 
-// GetMQServerPort - get mq port for server
-func GetMQServerPort() string {
-	port := "1883" //default
-	if os.Getenv("MQ_SERVER_PORT") != "" {
-		port = os.Getenv("MQ_SERVER_PORT")
-	} else if config.Config.Server.MQServerPort != "" {
-		port = config.Config.Server.MQServerPort
-	}
-	return port
-}
-
 // GetMqPassword - fetches the MQ password
 // GetMqPassword - fetches the MQ password
 func GetMqPassword() string {
 func GetMqPassword() string {
 	password := ""
 	password := ""