jasonrbriggs / stomp.py

“stomp.py” is a Python client library for accessing messaging servers (such as ActiveMQ or RabbitMQ) using the STOMP protocol (versions 1.0, 1.1 and 1.2). It can also be run as a standalone, command-line client for testing.
Apache License 2.0
491 stars 167 forks source link

Support context paths? #426

Closed Spitfire1900 closed 7 months ago

Spitfire1900 commented 7 months ago

It doesn't appear from the API reference that stomp.py supports custom context paths, e.g. localhost:80/myapp/my_websocket_endpoint

Spitfire1900 commented 7 months ago

Confirming, while WSStompConnection supports a ws_path argument, WSStompConnection does not appear to ever be invoked.

Spitfire1900 commented 7 months ago

Resolved

import os
from base64 import b64encode

import stomp
from dotenv import load_dotenv
load_dotenv()

password = os.environ['password']
username = os.environ['USERNAME']

conn = stomp.WSStompConnection(
        [('example.com', 80)],
        ws_path='/myapp/my_websocket_endpoint',
        header={'Authorization': f"Basic {b64encode(f'{username}:{password}'.encode()).decode()}"}
    )

conn.connect(wait=True, with_connect_command=True) # returns None