Help connect to the server via MQTT?

301 views
Skip to first unread message

Влад Киселев

unread,
Oct 6, 2020, 5:24:46 AM10/6/20
to DroidScript
Please tell me how, using this command client = mqtt.connect (''), Connect to the server if I have login, password, and id client? 

Влад Киселев

unread,
Oct 6, 2020, 3:07:38 PM10/6/20
to DroidScript
Please help, I really need it.  Thanks.
вторник, 6 октября 2020 г. в 12:24:46 UTC+3, Влад Киселев:

Symbroson

unread,
Oct 6, 2020, 4:52:58 PM10/6/20
to DroidScript
how about reading the documentation or reading tutorials
I fount this right away

Влад Киселев

unread,
Oct 6, 2020, 5:23:07 PM10/6/20
to DroidScript
Unfortunately, I couldn't find where to enter the login, password and client id there.  Sorry, I don't understand English well.  Could you please write a string to connect to mqtt server ???
вторник, 6 октября 2020 г. в 23:52:58 UTC+3, Symbroson:
Message has been deleted

Symbroson

unread,
Oct 6, 2020, 5:40:09 PM10/6/20
to DroidScript
I can't give you more information than the link to the docs about mqtt because I never used it myself
Use a translator if you're not good at english. But you won't get far without learning english at least a little bit

Влад Киселев

unread,
Oct 8, 2020, 10:28:19 AM10/8/20
to DroidScript
Can anyone else know, please tell me ??
среда, 7 октября 2020 г. в 00:40:09 UTC+3, Symbroson:

Alan Hendry

unread,
Oct 8, 2020, 11:32:57 AM10/8/20
to DroidScript
Hi,
I don't understand any of this stuff ...
Regards, ah

Влад Киселев

unread,
Oct 8, 2020, 1:18:29 PM10/8/20
to DroidScript
Unfortunately, I did not understand anything from this either.
 All I found was this line client = mqtt.connect ('mqtt: // server ....', [{port:, username: '****', password: '****'}]  );  But unfortunately it does not work and it is not clear where to enter Clienid :(
 Please help who is familiar with this, it is very necessary.

 client = mqtt.connect ('mqtt: // server ....', [{port:, clientid: '****', username: '****', password: '****'}  ]);  -   does not work.
 client = mqtt.connect ('mqtt: // server ....', [{port:, id: '****', username: '****', password: '****'}  ]);  -   does not work.
 client = mqtt.connect ('mqtt: // server ....', [{port:, idclient: '****', username: '****', password: '****'}  ]);  -   does not work.
четверг, 8 октября 2020 г. в 18:32:57 UTC+3, hendr...@gmail.com:

Влад Киселев

unread,
Oct 10, 2020, 3:57:33 AM10/10/20
to DroidScript
Guys, please help.  Hasn't anyone used the mqtt plugin?
 Why is it not specified in the plugin documentation where to enter authorization data (((
четверг, 8 октября 2020 г. в 20:18:29 UTC+3, Влад Киселев:

Jo Elegolo

unread,
Oct 10, 2020, 2:16:20 PM10/10/20
to DroidScript
Hi!
As being told, You should try to understand first, how MQTT is working.
This is the specification for MQTT 3.1.1:
As ou can see in chapter 3.1, the client's connect to the server/"broker" may take username and password if defined at all (there may be broker that work without that) BUT NO clientid. The clientid is what the broker gives back to the connecting client so that the client can and must use this to identify himself further on UNTIL the client (or server) closes the connection. The broker needs this id to identify the client.The use of this id may be performed INTERNALLY by the client module, so the module's user will never make use of this id either.
As the DS MQTT is a port of the node.js MQTT implementation, you can look at the links Symbroson told You 4 days ago.
Why would You implement things You do not understand? How would You ever debug your work when not knowing what and where something go wrong? And there will.

Jo

Влад Киселев

unread,
Oct 10, 2020, 2:39:50 PM10/10/20
to DroidScript
When the sim800 module is connected to the server, all libraries provide an opportunity to enter a login, password and cliendid, and everything connects perfectly. Since on the broker's website I needed to come up with and add client identifiers that can connect to the server. And without this clientid does not start up on the server. Why can't I specify the clientid here, which I indicated on the broker's website. As a result of this, I am unable to connect to the server. Even in any application, to work with mqtt from the play market, you need to enter a username, password and clientid. (for example MQTT Dash). Tell me at least where to specify the username and password? In the examples, only lines of code with the server and port. Please help a beginner. Write one line of code for me.

суббота, 10 октября 2020 г. в 21:16:20 UTC+3, Jo Elegolo:

Jo Elegolo

unread,
Oct 10, 2020, 3:29:13 PM10/10/20
to DroidScript
Sorrry, maybe I've been wrong with what I have told, but I am not an experienced MQTT user and never used the MQTT.js plugin or node.js-module. BUT, I've looked to the options definition where you can find the parameter "clientId" written with a capial i what is relevant for identification of names. So try to use clientId:..., not clientid:... as You used in your test.

Hope, that helps ...
Jo

Влад Киселев

unread,
Oct 10, 2020, 3:32:04 PM10/10/20
to DroidScript
Tried it, unfortunately it doesn't help (

суббота, 10 октября 2020 г. в 22:29:13 UTC+3, Jo Elegolo:

Jo Elegolo

unread,
Oct 10, 2020, 3:34:46 PM10/10/20
to DroidScript
capital i - of course, does it help?

Влад Киселев

unread,
Oct 10, 2020, 3:36:29 PM10/10/20
to DroidScript
No, it doesn't help. 

суббота, 10 октября 2020 г. в 22:34:46 UTC+3, Jo Elegolo:

Jo Elegolo

unread,
Oct 10, 2020, 3:38:33 PM10/10/20
to DroidScript
So, what is the error or debug output telling about?

Jo Elegolo

unread,
Oct 10, 2020, 3:42:51 PM10/10/20
to DroidScript
Какое сообщение об ошибке вы получаете

Jo Elegolo

unread,
Oct 10, 2020, 3:51:33 PM10/10/20
to DroidScript
You should not use the '[' ']' brackets here, only {...}.
Опустите квадратные скобки '[' ... ']'.

Jo Elegolo

unread,
Oct 10, 2020, 3:54:29 PM10/10/20
to DroidScript
Также опустите "port:,".
Dont use empty parameter 'port:,', this may overwrite/delete the standard port definition.

Jo Elegolo

unread,
Oct 10, 2020, 4:04:05 PM10/10/20
to DroidScript
So, is
client = mqtt.connect ('mqtt: // server ....', {clientId: '****', username: '****', password: '****'});
working? If not, what is debug or error telling? Maybe use app.Debug(client) - is this undefined?

Влад Киселев

unread,
Oct 10, 2020, 4:09:34 PM10/10/20
to DroidScript
Пишет: "failed. Error in connection establishment:net
суббота, 10 октября 2020 г. в 23:04:05 UTC+3, Jo Elegolo:

Влад Киселев

unread,
Oct 10, 2020, 4:49:30 PM10/10/20
to DroidScript
I changed a broker that does not require a clientId, but gives an error when connecting:
“failed: Connection closed before receiving s handshake response
Source : Line: 1"

суббота, 10 октября 2020 г. в 23:09:34 UTC+3, Влад Киселев:

Влад Киселев

unread,
Oct 10, 2020, 4:50:42 PM10/10/20
to DroidScript
Screenshot_20201010_234401_com.smartphoneremote.androidscriptfree.jpg

суббота, 10 октября 2020 г. в 23:49:30 UTC+3, Влад Киселев:

Jo Elegolo

unread,
Oct 10, 2020, 5:46:52 PM10/10/20
to DroidScript
Well, to me it seems as if the server is not providing the webservice protocol, which is necessary for use of ws://.... Unfortunately, this seems to be the only protocol, DS can perform as there are libs missing for other protocols. Просто предположение.
I think, there has been not so much testing about that topic since the plugin is available. I played around just now and could reproduce your error. But, even the example given on top of the plugin-description of MQTT  does not produce the expected output, but is working as such.
Omitting 'ws:' leads to "Missing protocol source: file:///sdcard/DroidScript/mqttchk/ Line:1, so the implementation is webservice based only on my opinion.

Влад Киселев

unread,
Oct 10, 2020, 6:17:46 PM10/10/20
to DroidScript
The broker indicated that port 6548 is a websocket.  If I specify a different port, the error: "does not support websocket" And with this port there is already another error, which is in the screenshot.

воскресенье, 11 октября 2020 г. в 00:46:52 UTC+3, Jo Elegolo:

Влад Киселев

unread,
Oct 11, 2020, 1:26:43 PM10/11/20
to DroidScript
People answer who used the Mqtt plugin ???  How to connect to the server using login and password ??  I have already tried 4 servers.  Of all, I can only connect to the test server plugin from the example, which is without a username and password.  Help!
воскресенье, 11 октября 2020 г. в 01:17:46 UTC+3, Влад Киселев:

Jo Elegolo

unread,
Oct 11, 2020, 5:39:05 PM10/11/20
to DroidScript
I am sorry, I cannot help you.
Modifying the connectTimeout parameter does not change the error result, so this might not be a timeout problem.
You can try to modify any of the other parameters of the options-object, the list of you find in the documentation of the plugin or at mqtt.js-website. I do not have any idea what to modify and how.
Maybe the problem lies in the underlying websocket implementation that is used by this plugin.

Влад Киселев

unread,
Oct 11, 2020, 5:52:41 PM10/11/20
to DroidScript
I hope that someone has already used it and can help me
понедельник, 12 октября 2020 г. в 00:39:05 UTC+3, Jo Elegolo:

Jo Elegolo

unread,
Oct 11, 2020, 6:17:56 PM10/11/20
to DroidScript
This forum does not seem to be helpful for You, as there is no one listening who is used to MQTT. Perhaps you should look for support for MQTT.js originally.
To get a better insight of what is set by default and how You can set parameters, use:
    client = mqtt.connect( 'ws://wqtt.ru:6548',
        {   
            reconnectPeriod: 5000,
            username: "Anton",
            password: "Checkov"
        } );
    app.WriteFile( "log.txt", JSON.stringify( client ).replace(/,/g, ',\n' ) );
to print the parameters of the client-object to log.txt (same path as your test program in DS).

Влад Киселев

unread,
Oct 12, 2020, 5:51:27 PM10/12/20
to DroidScript
There is a new problem. I can't build the application using the MQTT plugin. When launching the application, it gives an error:
"Error: / data / user / 0 / com ****** / app_Plugins / mqtt / MQTT.inc not found!"
Help me Please!
понедельник, 12 октября 2020 г. в 01:17:56 UTC+3, Jo Elegolo:

Steve Garman

unread,
Oct 13, 2020, 4:09:50 AM10/13/20
to DroidScript
It looks like the plugin has not been extracted to the APK

This can happen if you previously installed a version of the APK without the plugin and then installed the new version over the top of it without increasing the version number.

Try uninstalling the APK then install your new APK again

Влад Киселев

unread,
Oct 13, 2020, 4:41:20 AM10/13/20
to DroidScript
Thank you very much!
вторник, 13 октября 2020 г. в 11:09:50 UTC+3, steve....@gmail.com:

Влад Киселев

unread,
Oct 13, 2020, 7:58:03 AM10/13/20
to DroidScript
Please tell me how to prevent the application from going to sleep?  I need my application to constantly monitor the mqtt server in the background, but after a few minutes it stops.  I set setTimeout every 10 seconds but that doesn't help either.
вторник, 13 октября 2020 г. в 11:41:20 UTC+3, Влад Киселев:

Влад Киселев

unread,
Oct 13, 2020, 1:06:49 PM10/13/20
to DroidScript
Tried using service, didn't help.  Service also stops after a few minutes on the locked smartphone.  In the android settings, the application allowed autostart and work in the background.  What can you advise?  thanks
вторник, 13 октября 2020 г. в 14:58:03 UTC+3, Влад Киселев:
Reply all
Reply to author
Forward
0 new messages