piotr-rojek / devopsifyme-sbemulator

MIT License
66 stars 12 forks source link

Cannot establish AMQP connection. #22

Open jestemwojtek opened 1 year ago

jestemwojtek commented 1 year ago

Hi!

I'm trying to connect to emulator using python and it fails while establishing AMQP connection.

I think i know why I'm having an issue but first the details:

this is error from python:

  File "/Users/me/Wojtek/Project/venv/lib/python3.9/site-packages/azure/servicebus/aio/_base_handler_async.py", line 270, in _do_retryable_operation
    last_exception = await self._handle_exception(exception)
  File "/Users/me/Wojtek/Project/venv/lib/python3.9/site-packages/azure/servicebus/aio/_base_handler_async.py", line 211, in _handle_exception
    raise error
azure.servicebus.exceptions.ServiceBusError: Handler failed: <lambda>() missing 5 required positional arguments: 'outgoing_locales', 'incoming_locales', 'offered_capabilities', 'desired_capabilities', and 'properties'.

logs from emulator:

warn: ServiceBusEmulator.ServiceBusEmulatorHost[0]

      AMQP SSL errors RemoteCertificateNotAvailable.

[02:47:10.993] SEND AMQP 3 1 0 0
[02:47:10.994] SEND sasl-mechanisms(sasl-server-mechanisms:[MSSBCBS,EXTERNAL,ANONYMOUS])
[02:47:10.996] RECV sasl-init(mechanism:ANONYMOUS,initial-response:...,hostname:localhost)
[02:47:10.997] SEND sasl-outcome(code:Ok)
[02:47:10.997] SEND AMQP 0 1.0.0
[02:47:10.997] SEND (ch=0) open(container-id:AMQPNetLite-eacca698,host-name:localhost,max-frame-size:262144,channel-max:255,idle-time-out:1073741823)
[02:47:11.011] RECV AMQP 0 1 0 0
[02:47:11.012] RECV (ch=0) open(container-id:SBSender-71285097-eb44-4046-a90c-2358d5769591,host-name:localhost,max-frame-size:1048576,channel-max:65535,properties:[product:azsdk-python-servicebus,version:7.10.0,framework:Python/3.9.16,platform:macOS-13.4-x86_64-i386-64bit,user-agent:azsdk-python-servicebus/7.10.0 pyamqp/2.0.0a1 Python/3.9.16 (macOS-13.4-x86_64-i386-64bit)])
[02:47:11.013] RECV (ch=1) begin(next-outgoing-id:0,incoming-window:65536,outgoing-window:65536,handle-max:4294967295)
[02:47:11.013] SEND (ch=0) begin(remote-channel:1,next-outgoing-id:0,incoming-window:2048,outgoing-window:65536,handle-max:1023)
[02:47:11.013] RECV (ch=1) attach(name:e842e623-490e-46ac-8dd7-2c0886c4b60e,handle:2,role:True,snd-settle-mode:Unsettled,rcv-settle-mode:First,source:source(address:$cbs),target:target(address:$cbs))
[02:47:11.014] SEND (ch=0) attach(name:e842e623-490e-46ac-8dd7-2c0886c4b60e,handle:0,role:False,snd-settle-mode:Unsettled,rcv-settle-mode:First,source:source(address:$cbs),target:target(address:$cbs),initial-delivery-count:0,max-message-size:2147483647)
[02:47:11.014] RECV (ch=1) attach(name:cb997c48-8461-403a-97bf-0cd3af530d34,handle:1,role:False,snd-settle-mode:Unsettled,rcv-settle-mode:First,source:source(address:$cbs),target:target(address:$cbs),initial-delivery-count:0)
[02:47:11.014] SEND (ch=0) attach(name:cb997c48-8461-403a-97bf-0cd3af530d34,handle:1,role:True,snd-settle-mode:Unsettled,rcv-settle-mode:First,source:source(address:$cbs),target:target(address:$cbs),initial-delivery-count:0,max-message-size:2147483647)
[02:47:11.014] SEND (ch=0) flow(next-in-id:0,in-window:2048,next-out-id:0,out-window:65536,handle:1,delivery-count:0,link-credit:100,drain:False)
[02:47:11.060] RECV (ch=1) detach(handle:2,closed:True)
[02:47:11.061] SEND (ch=0) detach(handle:0,closed:True)
[02:47:11.061] RECV (ch=1) detach(handle:1,closed:True)
[02:47:11.061] SEND (ch=0) detach(handle:1,closed:True)
[02:47:11.061] RECV (ch=1) end()
[02:47:11.062] SEND (ch=0) end()
[02:47:11.062] RECV (ch=0) close()
[02:47:11.062] SEND (ch=0) close()
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 GET http://localhost/health - -
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished HTTP/1.1 GET http://localhost/health - - - 200 - text/plain 3.0091ms
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 GET http://localhost/health - -
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]

I believe there are some missing metadata in AMQP configuration. python documentation for frame object states:

"""
Process incoming Open frame to finish the connection negotiation.

The incoming frame format is::

    - frame[0]: container_id (str)
    - frame[1]: hostname (str)
    - frame[2]: max_frame_size (int)
    - frame[3]: channel_max (int)
    - frame[4]: idle_timeout (Optional[int])
    - frame[5]: outgoing_locales (Optional[List[bytes]])
    - frame[6]: incoming_locales (Optional[List[bytes]])
    - frame[7]: offered_capabilities (Optional[List[bytes]])
    - frame[8]: desired_capabilities (Optional[List[bytes]])
    - frame[9]: properties (Optional[Dict[bytes, bytes]])
"""

and frame that emulator sends looks like this: [b'AMQPNetLite-9da6f748', b'localhost', 262144, 255, 1073741823]

while frame received from actual service bus looks a bit different: [b’c7c56a778s8s9876’97687a876s6, None, 65555, 5111, 145949, None, None, None, None, None]

Not sure how to do that, but setting missing configuration fields to null would solve the issue.