saqura / xmppwb

XMPP Webhook Bridge [Archived]
MIT License
73 stars 8 forks source link

async def handle_outgoing(self, outgoing_webhook, msg): SyntaxError: invalid syntax #4

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hello Devs.

I'm playing around with xmppwb but with little success. After running:

xmppwb --config /etc/xmppwb/config.conf

i get:

Traceback (most recent call last):
  File "/usr/bin/xmppwb", line 9, in <module>
    load_entry_point('xmppwb==0.2.6', 'console_scripts', 'xmppwb')()
  File "/usr/lib64/python3.4/site-packages/pkg_resources/__init__.py", line 558, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib64/python3.4/site-packages/pkg_resources/__init__.py", line 2682, in load_entry_point
    return ep.load()
  File "/usr/lib64/python3.4/site-packages/pkg_resources/__init__.py", line 2355, in load
    return self.resolve()
  File "/usr/lib64/python3.4/site-packages/pkg_resources/__init__.py", line 2361, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib64/python3.4/site-packages/xmppwb/core.py", line 17, in <module>
    from xmppwb.bridge import XMPPWebhookBridge, InvalidConfigError
  File "/usr/lib64/python3.4/site-packages/xmppwb/bridge.py", line 90
    async def handle_outgoing(self, outgoing_webhook, msg):
            ^
SyntaxError: invalid syntax

The specific snippet looks like:

    outgoing_webhooks:
      # Note: "Outgoing from this bridge" means "Incoming to RocketChat",
      # so this URL refers to the incoming webhook URL of RocketChat.
      - url: https://domain/hooks/....deleted
        override_username: "{nick}"
        message_template: "_{msg}_"
        use_attachment_formatting: true

Any suggestions?

thanks and cheers

jeremyrichardmann commented 8 years ago

Requires python 3.5, i'd start there.

ghost commented 8 years ago

Uh. I was pretty sure i was using 3.5. I'll try again.

thanks and cheers t.

ghost commented 8 years ago

Okiedokie. The Syntax error is gone now. But now i get.

pages ~ # xmppwb --config /etc/xmppwb/config.conf 
04-18:28:40 INFO     Using config file /etc/xmppwb/config.conf
04-18:28:40 INFO     Listening for incoming webhooks on http://127.0.0.1:5000/
04-18:28:40 ERROR    Exception in callback _SelectorSocketTransport._read_ready()
handle: <Handle _SelectorSocketTransport._read_ready()>
Traceback (most recent call last):
  File "/usr/lib64/python3.5/asyncio/selector_events.py", line 660, in _read_ready
    data = self._sock.recv(self.max_size)
AttributeError: 'NoneType' object has no attribute 'recv'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.5/asyncio/events.py", line 125, in _run
    self._callback(*self._args)
  File "/usr/lib64/python3.5/asyncio/selector_events.py", line 664, in _read_ready
    self._fatal_error(exc, 'Fatal read error on socket transport')
  File "/usr/lib64/python3.5/asyncio/selector_events.py", line 584, in _fatal_error
    self._loop.call_exception_handler({
AttributeError: 'NoneType' object has no attribute 'call_exception_handler'

There is something running on 127.0.0.1:5000 but no connection to my openfire server.

Any hints?

thanks t.

saqura commented 8 years ago

Which version of xmppwb are you using? The latest git version or the latest from pypi? Also, can you start xmppwb with the -v and -d flags and post the debug output?

ghost commented 8 years ago

here we go:

pages ~ # xmppwb -v -d --config /etc/xmppwb/config.conf 
04-18:55:34 INFO     Using config file /etc/xmppwb/config.conf
04-18:55:34 DEBUG    Get address info 127.0.0.1:5000, type=<SocketKind.SOCK_STREAM: 1>, flags=1
04-18:55:34 DEBUG    Getting address info 127.0.0.1:5000, type=<SocketKind.SOCK_STREAM: 1>, flags=1 took 0.032 ms: [(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('127.0.0.1', 5000))]
04-18:55:34 INFO     <Server sockets=[<socket.socket fd=6, family=AddressFamily.AF_INET, type=2049, proto=6, laddr=('127.0.0.1', 5000)>]> is serving
04-18:55:34 INFO     Listening for incoming webhooks on http://127.0.0.1:5000/
04-18:55:34 DEBUG    poll 999.764 ms took 0.232 ms: 1 events
04-18:55:34 DEBUG    poll 999.909 ms took 0.330 ms: 1 events
04-18:55:34 DEBUG    Get address info 138.201.43.27:5222, type=<SocketKind.SOCK_STREAM: 1>
04-18:55:34 DEBUG    Getting address info 138.201.43.27:5222, type=<SocketKind.SOCK_STREAM: 1> took 0.020 ms: [(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('138.201.43.27', 5222))]
04-18:55:34 DEBUG    connect <socket.socket fd=7, family=AddressFamily.AF_INET, type=2049, proto=6, laddr=('0.0.0.0', 0)> to ('138.201.43.27', 5222)
04-18:55:34 DEBUG    poll took 0.059 ms: 1 events
04-18:55:34 DEBUG    <_SelectorSocketTransport fd=7 read=idle write=<idle, bufsize=0>>: Fatal write error on socket transport
Traceback (most recent call last):
  File "/usr/lib64/python3.5/asyncio/selector_events.py", line 698, in write
    n = self._sock.send(data)
ConnectionResetError: [Errno 104] Connection reset by peer
04-18:55:34 DEBUG    <socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=2049, proto=6> connected to 138.201.43.27:5222: (<_SelectorSocketTransport closed fd=7>, <xmppwb.xmpp.XMPPBridgeBot object at 0x7fb8311fa550>)
04-18:55:34 ERROR    Exception in callback _SelectorSocketTransport._read_ready()
handle: <Handle _SelectorSocketTransport._read_ready() created at /usr/lib64/python3.5/asyncio/selector_events.py:232>
source_traceback: Object created at (most recent call last):
  File "/usr/bin/xmppwb", line 9, in <module>
    load_entry_point('xmppwb==0.2.6', 'console_scripts', 'xmppwb')()
  File "/usr/lib64/python3.5/site-packages/xmppwb/core.py", line 77, in main
    bridge.process()
  File "/usr/lib64/python3.5/site-packages/xmppwb/bridge.py", line 88, in process
    self.loop.run_forever()
  File "/usr/lib64/python3.5/asyncio/base_events.py", line 301, in run_forever
    self._run_once()
  File "/usr/lib64/python3.5/site-packages/slixmpp/xmlstream/asyncio.py", line 24, in my_run_once
    real_run_once(self)
  File "/usr/lib64/python3.5/asyncio/base_events.py", line 1190, in _run_once
    handle._run()
  File "/usr/lib64/python3.5/asyncio/events.py", line 125, in _run
    self._callback(*self._args)
  File "/usr/lib64/python3.5/asyncio/selector_events.py", line 232, in add_reader
    handle = events.Handle(callback, args, self)
Traceback (most recent call last):
  File "/usr/lib64/python3.5/asyncio/selector_events.py", line 660, in _read_ready
    data = self._sock.recv(self.max_size)
AttributeError: 'NoneType' object has no attribute 'recv'
saqura commented 8 years ago

I tried connecting to this XMPP server, but can't reproduce this error. Can you post your config? (Blank things like your password, of course.)

ghost commented 8 years ago
# vim: syntax=yaml

# Example configuration for bridging XMPP with RocketChat.
#
# The <placeholders> need to be filled out.
#
# This would connect to the XMPP MUC "conference1" using the account
# "alice" and relay messages to and from this MUC to a RocketChat-instance,
# as specified by the webhooks. The webhooks need to be configured in
# RocketChat aswell.
#
# Refer to the README for detailed documentation of all settings.
xmpp:
  jid: rocketbridge@dings.meine-oma.de  
  password: "changed"

  # A list of all MUCs that should be available to the bridges defined later.
  mucs:
    - jid: rocketbridge@conference.dings.meine-oma.de
      nickname: rocketbridge
      # password: "<muc-password>"

incoming_webhook_listener:
  # The outgoing webhook URL that must be set in Rocket.Chat is of the form
  # "http://{bind_adress}:{port}/".
  bind_address: "127.0.0.1"
  port: 5000

bridges:
  - xmpp_endpoints:
      - muc: rocketbridge@conference.dings.meine-oma.de
      # - normal: <bob@example.com>
      # - relay_all_normal: true

    outgoing_webhooks:
      # Note: "Outgoing from this bridge" means "Incoming to RocketChat",
      # so this URL refers to the incoming webhook URL of RocketChat.
      - url: https://chat.meine-oma.de/hooks/N.....
        override_username: "{nick}"
        message_template: "_{msg}_"
        use_attachment_formatting: true

    incoming_webhooks:
      # Note: "Incoming to this bridge" means "Outgoing from RocketChat",
      # so this token must match the token in the outgoing webhook from
      # RocketChat.
      - token: blub
ghost commented 8 years ago

I tried to connect with that user and the android app xabber. Worked. Thanks for your support.

ghost commented 8 years ago

Oh dear. It works now. It was a firewall issue. What else. Sorry for the noise. I'm now going to test it.

thanks for your patience t.

saqura commented 8 years ago

I'm glad that it works now. Just open another issue if there are any bugs.