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

How to connect to the amazonmq broker like ssl://b-62f0ce63-0-1.mq.cn-north-1.amazonaws.com.cn:61617? #376

Open
alterhu2020 opened this issue Apr 19, 2022 · 3 comments

Comments

@alterhu2020
Copy link

alterhu2020 commented Apr 19, 2022

For java client we can connect amazonMQ like the following broker failover url:

failover:(ssl://b-62f0ce63-0-1.mq.cn-north-1.amazonaws.com.cn:61617,ssl://b-62f0ce63-0-2.mq.cn-north-1.amazonaws.com.cn:61617)?randomize=true

but when I use with stomp.py like the following code:

    host_and_ports = []
    hosts = ["b-62f0ce63-0-1.mq.cn-north-1.amazonaws.com.cn:61617",
             "b-62f0ce63-0-2.mq.cn-north-1.amazonaws.com.cn:61617"]
    for host in hosts:
        host_and_port = list(host.split(':'))
        host_and_port[1] = int(host_and_port[1])
        host_and_ports.append(tuple(host_and_port))
    con = stomp.Connection(
        host_and_ports=host_and_ports
    )
    listener = TestListener(print_to_log=True)
    con.set_listener('latest_logging', listener)
    con.connect(username='xxx', passcode='xxxxx', with_connect_command=True, wait=True)

It will throw the following errors:

Could not connect to host b-62f0ce63-0-1.mq.cn-north-1.amazonaws.com.cn, port 61617
Unknown response frame type: '�;�activemq' (frame length was 11)
Unknown response frame type: '�' (frame length was 2)
Unknown response frame type: '�)' (frame length was 2)
Unknown response frame type: '' (frame length was 1)
Unknown response frame type: '�tcpnodelayenabled��' (frame length was 20)
Unknown response frame type: '�sizeprefixdisabled�' (frame length was 20)
Unknown response frame type: '	cachesize�' (frame length was 11)
Unknown response frame type: '�' (frame length was 1)
Unknown response frame type: 'providername	' (frame length was 14)
Unknown response frame type: activemq' (frame length was 9)
Unknown response frame type: '�stacktraceenabled��' (frame length was 20)
Unknown response frame type: '�platformdetails	' (frame length was 17)
Unknown response frame type: '�java' (frame length was 5)
Unknown response frame type: 'cacheenabled��' (frame length was 15)
Unknown response frame type: '�tightencodingenabled��' (frame length was 23)
Unknown response frame type: 'maxframesize�' (frame length was 14)
Unknown response frame type: '�@' (frame length was 2)
Unknown response frame type: '�maxinactivityduration�' (frame length was 23)
Unknown response frame type: 'u0' (frame length was 2)
Unknown response frame type: ' maxinactivitydurationinitaldelay�' (frame length was 34)
Unknown response frame type: ''�' (frame length was 2)
Unknown response frame type: '�providerversion	' (frame length was 17)
Traceback (most recent call last):
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1483, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/Users/peter/try_mq.py", line 22, in <module>
    con.connect(username='xxxx', passcode='xxxxx', with_connect_command=True, wait=True)
  File "/Users/peter/opt/miniconda3/envs/python310/lib/python3.10/site-packages/stomp/connect.py", line 151, in connect
    Protocol11.connect(self, *args, **kwargs)
  File "/Users/peter/opt/miniconda3/envs/python310-latest/lib/python3.10/site-packages/stomp/protocol.py", line 339, in connect
    self.transport.wait_for_connection()
  File "/Users/peter/opt/miniconda3/envs/python310-latest/lib/python3.10/site-packages/stomp/transport.py", line 344, in wait_for_connection
    raise exception.ConnectFailedException()
stomp.exception.ConnectFailedException

any clue for this? thanks for team's help

@jasonrbriggs
Copy link
Owner

I don't use amazon, but if you're connecting to ssl URLs with java, you need to connect using ssl with Python. Example here: https://github.com/jasonrbriggs/stomp.py/blob/dev/tests/test_ssl.py

@Dhyanesh97
Copy link

Dhyanesh97 commented Apr 25, 2022

@alterhu2020 Have you tried connecting to amazon active MQ? Are you able to successfully connect?

@alterhu2020
Copy link
Author

alterhu2020 commented Jul 10, 2022

Hi @Dhyanesh97
Not yet now. When i search from our server side code found that it can connect as following code:

    @Bean
    public ConnectionFactory connectionFactory() {
        return new ActiveMQConnectionFactory(username, password, brokerUrl);
    }

which only need these arguments:

  • username
  • password
  • brokerUrl

The above document need to use key_file='tmp/client.key', cert_file='tmp/client.pem', ca_certs='tmp/broker2.pem' that's not the correct way I think. Anyone can help for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants