0

I'm trying to use python-qpid-proton version 0.9.1 to send a message to a Azure Service Bus queue.

The examples in examples/python/messenger/ accept addresses of the form amqps://:@/, and I can successfully send messages to the queue I have on Azure with it. The problem with this is that I can't control much of what's going on, namely I can't really see if the sending failed. Eventually I want to persist the messages in case the internet connection goes down temporarily.

The example code examples/python/db_send.py and examples/python/simple_send.py seem to be more useful with this aspects, as they use the MessagingHandler instead of the Messenger class. But when I run them, I get this error:

 ./simple_send.py -a amqps://send:mxirestofmypassword@testsoton.servicebus.windows.net/queue2
Traceback (most recent call last):
 File "./simple_send.py", line 62, in <module>
    Container(Send(opts.address, opts.messages)).run()
  File "/usr/local/lib/python2.7/dist-packages/proton/reactor.py", line 120, in run
    while self.process(): pass
  File "/usr/local/lib/python2.7/dist-packages/proton/reactor.py", line 143, in proce
    self._check_errors()
  File "/usr/local/lib/python2.7/dist-packages/proton/__init__.py", line 3737, in dis
    ev.dispatch(self.handler)
  File "/usr/local/lib/python2.7/dist-packages/proton/__init__.py", line 3662, in dis
    result = dispatch(handler, type.method, self)
  File "/usr/local/lib/python2.7/dist-packages/proton/__init__.py", line 3551, in dis
    return m(*args)
  File "/usr/local/lib/python2.7/dist-packages/proton/handlers.py", line 416, in on_r
    self.on_start(event)
  File "./simple_send.py", line 36, in on_start
    event.container.create_sender(self.url)
  File "/usr/local/lib/python2.7/dist-packages/proton/reactor.py", line 671, in creat
    session = self._get_session(context)
  File "/usr/local/lib/python2.7/dist-packages/proton/reactor.py", line 634, in _get_
    return self._get_session(self.connect(url=context))
  File "/usr/local/lib/python2.7/dist-packages/proton/reactor.py", line 611, in conne
    if url: connector.address = Urls([url])
  File "/usr/local/lib/python2.7/dist-packages/proton/reactor.py", line 555, in __ini
    self.values = [Url(v) for v in values]
  File "/usr/local/lib/python2.7/dist-packages/proton/__init__.py", line 3851, in __i
    if defaults: self.defaults()
  File "/usr/local/lib/python2.7/dist-packages/proton/__init__.py", line 3894, in def
    self.port = self.port or self.Port(self.scheme)
  File "/usr/local/lib/python2.7/dist-packages/proton/__init__.py", line 3868, in _ge
    return portstr and Url.Port(portstr)
  File "/usr/local/lib/python2.7/dist-packages/proton/__init__.py", line 3812, in __n
    port = super(Url.Port, cls).__new__(cls, cls._port_int(value))
  File "/usr/local/lib/python2.7/dist-packages/proton/__init__.py", line 3833, in _po
    raise ValueError("Not a valid port number or service name: '%s'" % value)
ValueError: Not a valid port number or service name: 'mxitheresto'

Seems to me like it does not parse the address correctly. I pasted the same address as before. And I also pasted it into the python interpreter, like this:

 import proto
 u =     proton.Url("amqps://send:mxirestofmypassword@testsoton.servicebus.windows.net/queue2")
 # no error, and I can access all the parameters:
 u.port
 5671
 u.username
 send
 # ...

It works fine if I use a local connection with no username and password. Gets past this point if I don't use any username and password but obviously does not work as it fails authentication.

Is there any way I can use the MessagingHandler class and specify username and password to send messages to a remote (like on Azure)?

Mika
  • 51
  • 6
  • The same question as the link http://stackoverflow.com/questions/32189596/python-qpid-proton-examples-send-message-to-azure-not-working/32197104?noredirect=1#comment52285281_32197104 – Peter Pan Aug 26 '15 at 02:11
  • Please move to http://stackoverflow.com/questions/32189596/python-qpid-proton-examples-send-message-to-azure-not-working/32197104?noredirect=1#comment52285281_32197104, the same question as yours. Best Regards. – Peter Pan Aug 26 '15 at 07:24

1 Answers1

-1

The examples examples/python/db_send.py and examples/python/simple_send.py request the Azure Service Bus is OK, but they can't establish the sender connection with AMQPS scheme.

Refer to the MSDN offical document https://msdn.microsoft.com/en-us/library/azure/jj841070.aspx, MS recommends to use Messenger Class to send messages.

The Details for your issue, please refer to my post at python-qpid-proton examples, send message to azure not working.

Community
  • 1
  • 1
Peter Pan
  • 23,476
  • 4
  • 25
  • 43