Подключение AWSMQ через python библиотеку Stomp в AWS лямбда - PullRequest
0 голосов
/ 08 мая 2020

Я пытаюсь подключиться к брокеру сообщений AWSMQ, используя Stomp библиотеку из AWS lambda в python. Ниже мой код:

# Imports
from __future__ import print_function
import time
import sys
import stomp    

    def lambda_handler(event, context):
    # TODO implement
    message_to_mq()

    def message_to_mq():
    print ("send message to MQ")
    conn = stomp.Connection()
    conn.set_ssl(for_hosts=[('stomp+ssl://<end point>', <port>)])
    conn.connect('<username>', '<password>', wait=True)
    time.sleep(2)
    conn.disconnect()

Но получаю следующую ошибку:

Response:
{
  "errorType": "ConnectFailedException",
  "stackTrace": [
    "  File \"/awsmq.py\", line 10, in lambda_handler\n    message_to_mq()\n",
    "  File \"/awsmq.py\", line 17, in message_to_mq\n    conn.connect('<username>', '<password>', wait=True)\n",
    "  File \"/stomp/connect.py\", line 161, in connect\n    self.transport.start()\n",
    "  File \"/stomp/transport.py\", line 104, in start\n    self.attempt_connection()\n",
    "  File \"/stomp/transport.py\", line 800, in attempt_connection\n    raise exception.ConnectFailedException()\n"
  ]
}

Журналы функций:

send message to MQ
[WARNING]   Could not connect to host localhost, port 61613
Traceback (most recent call last):
  File "/stomp/transport.py", line 727, in attempt_connection
    self.socket = socket.create_connection(host_and_port, self.__timeout)
  File "/socket.py", line 728, in create_connection
    raise err
  File "/socket.py", line 711, in create_connection
    sock = socket(af, socktype, proto)
  File "/socket.py", line 151, in __init__
    _socket.socket.__init__(self, family, type, proto, fileno)
    OSError: [Errno 97] Address family not supported by protocol
    [WARNING] Could not connect to host localhost, port 61613
    Traceback (most recent call last):
  File "/stomp/transport.py", line 727, in attempt_connection
    self.socket = socket.create_connection(host_and_port, self.__timeout)
  File "/socket.py", line 728, in create_connection
    raise err
  File "/socket.py", line 711, in create_connection
    sock = socket(af, socktype, proto)
  File "/socket.py", line 151, in __init__
    _socket.socket.__init__(self, family, type, proto, fileno)
...