Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using an existing MQTT server #6

Open
mijnmodelbaan opened this issue Aug 3, 2019 · 6 comments
Open

using an existing MQTT server #6

mijnmodelbaan opened this issue Aug 3, 2019 · 6 comments

Comments

@mijnmodelbaan
Copy link

mijnmodelbaan commented Aug 3, 2019

Hi,

I would like to use my existing MQTT server (mosquitto) with your program. Is this possible and if yes, how do I accomplish that? I'm not really Raspberry/Linux savvy so I need some guidance in this.

I already tried to put the IP number of my server in Utility.js, but then I get the following error:

~/Virtual-Tasmota-for-Tuya-api-devices $ nodemon --ext rs tuya_api_mqtt.js
[nodemon] 1.19.1
[nodemon] to restart at any time, enter rs
[nodemon] watching: .
[nodemon] starting node tuya_api_mqtt.js
Web Server Running on Port 8082
CDN Running on Port 2362
events.js:174
throw er; // Unhandled 'error' event
^

Error: Connection refused: Not authorized
at MqttClient._handleConnack (/home/pi/Virtual-Tasmota-for-Tuya-api-devices/node_modules/mqtt/lib/client.js:1076:15)
at MqttClient._handlePacket (/home/pi/Virtual-Tasmota-for-Tuya-api-devices/node_modules/mqtt/lib/client.js:365:12)
at work (/home/pi/Virtual-Tasmota-for-Tuya-api-devices/node_modules/mqtt/lib/client.js:283:12)
at Writable.writable._write (/home/pi/Virtual-Tasmota-for-Tuya-api-devices/node_modules/mqtt/lib/client.js:294:5)
at doWrite (/home/pi/Virtual-Tasmota-for-Tuya-api-devices/node_modules/readable-stream/lib/_stream_writable.js:428:64)
at writeOrBuffer (/home/pi/Virtual-Tasmota-for-Tuya-api-devices/node_modules/readable-stream/lib/_stream_writable.js:417:5)
at Writable.write (/home/pi/Virtual-Tasmota-for-Tuya-api-devices/node_modules/readable-stream/lib/_stream_writable.js:334:11)
at Socket.ondata (_stream_readable.js:709:20)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
Emitted 'error' event at:
at MqttClient._handleConnack (/home/pi/Virtual-Tasmota-for-Tuya-api-devices/node_modules/mqtt/lib/client.js:1078:10)
at MqttClient._handlePacket (/home/pi/Virtual-Tasmota-for-Tuya-api-devices/node_modules/mqtt/lib/client.js:365:12)
[... lines matching original stack trace ...]
at addChunk (_stream_readable.js:288:12)
[nodemon] app crashed - waiting for file changes before starting...

I would like to use my existing MQTT server as there are other devices and programs using it.

Thanks for a reply.

@thirug010
Copy link
Owner

Sorry for the Delay I was out of station.

I am using "mosquitto" myself it is working just fine. I will check and update you

@thirug010
Copy link
Owner

thirug010 commented Aug 21, 2019

@mijnmodelbaan,

I guess your configued Mqtt as secure connection mode, I have updated the code to use username, password for mqtt server.

Get latest and update the mqtt server config and let me know, check on the mqtt server you should see vir_tasmota_001 client connected

Update the following MQttserver information in the "Utility.js"

  • Utility.mqttServer = 'mqtt://xxx.xxx.x.xxx:yyyy'; // Mqtt server ip and port
  • Utility.mqttUsername = 'xxxxxx'; // Mqtt server username
  • Utility.mqttPassword = 'xxxxx'; // Mqtt server username
  • Utility.mqttUseSequreLogin = true; // set true to use mqtt with username and password
  • Utility.mqttClientId = 'vir_tasmota_001'; // Mqtt client name

@mijnmodelbaan
Copy link
Author

Hi,
Thanks for your answer and effort and I'll give it a try.
Is the client name 'vir_tasmota_001' mandatory or can I change it ?
BR//Willem.

@thirug010
Copy link
Owner

@mijnmodelbaan,

you can change it will be use to display on mosquitte server as client "youname" connect with ip address that is all. this is to identify your client connect by default it will named as nodejs_somerandom numbers

@thirug010
Copy link
Owner

@mijnmodelbaan, Any update ?

@mijnmodelbaan
Copy link
Author

mijnmodelbaan commented Aug 31, 2019

No update, yet. Very busy with other stuff, it'll have to wait.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants