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

i don't know how to pass the correct parameters in this version #846

Closed
ndertaker opened this issue May 25, 2024 · 2 comments
Closed

i don't know how to pass the correct parameters in this version #846

ndertaker opened this issue May 25, 2024 · 2 comments
Labels
Status: Available No one has claimed responsibility for resolving this issue. Status: More info needed More information needed from issue author

Comments

@ndertaker
Copy link

ndertaker commented May 25, 2024

This is my _messenger_queue_publish()

def _messenger_queue_publish(client: mqtt.Client, userdata, rc):
               topics = None
                
               queue = {
                    "sync_api_version": 10,
                    "max_deltas_able_to_process": 1000,
                    "delta_batch_size": 500,
                    "encoding": "JSON",
                    "entity_fbid": self.dataFB['FacebookID']
               }
               
               if (self.syncToken == None):
                    topics = "/messenger_sync_create_queue"
                    queue["initial_titan_sequence_id"] = self.lastSeqID
                    queue["device_params"] = None
               else:
                    topics = "/messenger_sync_get_diffs"
                    queue["last_seq_id"] = self.lastSeqID
                    queue["sync_token"] = "1"
               
               client.publish(
                    topics,
                    json_minimal(queue),
                    qos=1,
                    retain=False,
               )
self.mqtt = mqtt.Client(
               mqtt.CallbackAPIVersion.VERSION2,
               client_id=options["client_id"],
               clean_session=options["clean"],
               protocol=mqtt.MQTTv31,
               transport="websockets",
          )
          
          self.mqtt.tls_set(certfile=None, keyfile=None, cert_reqs=ssl.CERT_NONE, tls_version=ssl.PROTOCOL_TLSv1_2)
          
          self.mqtt.on_connect = _messenger_queue_publish
          self.mqtt.on_message = on_message
          self.mqtt.on_disconnect = on_disconnect
          
          self.mqtt.username_pw_set(username=options["username"])
          parsed_host = urlparse(host)
          
          self.mqtt.ws_set_options(
               path=f"{parsed_host.path}?{parsed_host.query}",
               headers=options["ws_options"]["headers"],
          )
          
          # connect
          self.mqtt.connect(
               host=options["ws_options"]["headers"]["Host"],
               port=443,
               keepalive=options["keepalive"],
          )
          self.mqtt.loop_forever()

The error:

Traceback (most recent call last):
  File "/storage/emulated/0/Download/lon/listen.py", line 202, in <module>
    _.connect_mqtt()
  File "/storage/emulated/0/Download/lon/listen.py", line 196, in connect_mqtt
    self.mqtt.loop_forever()
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/paho/mqtt/client.py", line 2297, in loop_forever
    rc = self._loop(timeout)
         ^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/paho/mqtt/client.py", line 1686, in _loop
    rc = self.loop_read()
         ^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/paho/mqtt/client.py", line 2100, in loop_read
    rc = self._packet_read()
         ^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/paho/mqtt/client.py", line 3142, in _packet_read
    rc = self._packet_handle()
         ^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/paho/mqtt/client.py", line 3814, in _packet_handle
    return self._handle_connack()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/paho/mqtt/client.py", line 3934, in _handle_connack
    on_connect(
TypeError: listeningEvent.connect_mqtt.<locals>._messenger_queue_publish() takes 3 positional arguments but 5 were given
@github-actions github-actions bot added the Status: Available No one has claimed responsibility for resolving this issue. label May 25, 2024
@MattBrittan
Copy link
Contributor

migrations.rst is a good place to start. This includes the example:

# NEW code for both version
def on_connect(client, userdata, flags, reason_code, properties):
    if flags.session_present:
        # ...
    if reason_code == 0:
        # success connect
    if reason_code > 0:
        # error processing

Note how the callback signiture differs from yours: def _messenger_queue_publish(client: mqtt.Client, userdata, rc):

I'm going to flag this as more info needed as I'm unclear if the above is what you are looking for.

@MattBrittan MattBrittan added the Status: More info needed More information needed from issue author label Jul 17, 2024
@ndertaker
Copy link
Author

Thanks for the reply.
I fixed them, it was a syntax error because I didn't read the docs carefully. Once again, thanks for answering my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Available No one has claimed responsibility for resolving this issue. Status: More info needed More information needed from issue author
Projects
None yet
Development

No branches or pull requests

2 participants