-1
我在我的网站上使用mqtt作为消息系统。那么在我的本地机器一切正常,但在我的网站(生产),我得到一个错误:MQTT 1884连接失败
我我的web服务器内使用Ubuntuvendor.bbaf8c4….bundle.js:1 WebSocket connection to 'ws://localhost:1884/mqtt' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
,我给端口1884年自由。
这个错误的含义是什么?
我使用Angular4我加内AfterViewInit
ngAfterViewInit() {
setTimeout(()=>{
this.messageservice.createMqttConnection(this.userId);
}, 200)
}
我的客户现场与泛美卫生组织的连接看起来像连接:
this._client = new Paho.MQTT.Client("localhost", 1884, id.toString());
让我的假设是域应mydomain.com我用localhost替换它?
在您的应用程序的主机名需要指向您的域名如:
localhost是运行代码的机器的地址,我假设这需要更改为指向您的生产环境 – hardillb
ok让我们假设我的域名是mydomain.com,我应该用localhost替换它吗? this._client = new Paho.MQTT.Client(“localhost”,1884,id.toString()); –
另一种方法,你应该用'mydomain.com'替换'localhost' – hardillb