mqtt.subscribe print -1 and it doesn't mqtt.publish

Here we can discuss about the problem found
Post Reply
Helmut_number_one
Posts: 102
Joined: Fri Dec 09, 2022 10:03 am
Has thanked: 45 times
Been thanked: 10 times

mqtt.subscribe print -1 and it doesn't mqtt.publish

Post by Helmut_number_one »

Hm mqtt.subscribe don't running, in a another Prg Virtuinio it is ok with this Topic

Code: [Local Link Removed for Guests]

' MQTT test program

' Using Helmuts test server

print mqtt.setup("http://192.168.0.9",1883)

print mqtt.connect("ccc", "ddd") ' No login / pass required
  pause 100 / it doesn't help

print mqtt.subscribe("/Power") ' subscribe to the topic /   my Power, not AnnexTest
  pause 100 / it doesn't help

onmqtt mqtt_msg 

for z = 1 to 10

  ' send messages to the topic AnnexTest

  print mqtt.publish("/AnnexTest", "Annex"+str$(z))

  pause 100

next z

print ramfree

wait

' receive messages from the server

mqtt_msg:

print "TOPIC  : "; mqtt.topic$

print "MESSAGE: "; mqtt.message$

return
Printed:
Program Running<\r><\n>
0<\r><\n>
0<\r><\n>
-1<\r><\n>
ESP has Annex32 CAN 1.52.9 LFS
what i make wrong?
User avatar
cicciocb
Site Admin
Posts: 2083
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 447 times
Been thanked: 1371 times
Contact:

Re: mqtt.subscribe print -1 and it doesn't mqtt.publish

Post by cicciocb »

Maybe this should be "mqtt://" instead of "http://" ?
image.png
You do not have the required permissions to view the files attached to this post.
Helmut_number_one
Posts: 102
Joined: Fri Dec 09, 2022 10:03 am
Has thanked: 45 times
Been thanked: 10 times

Re: mqtt.subscribe print -1 and it doesn't mqtt.publish

Post by Helmut_number_one »

Thank you,
In your Help"Wiki " i set the pause to 1000 ms, so can i see in MQTT server the z-variable.

Code: [Local Link Removed for Guests]

for z = 1 to 10
  ' send messages to the topic /AnnexTest
  print mqtt.publish("/AnnexTest", "Annex"+str$(z))
  pause 1000
next z
Post Reply