minghuaw / fe2o3-amqp

A rust implementation of the AMQP1.0 protocol based on serde and tokio.
MIT License
64 stars 7 forks source link

Allow Sec-WebSocket-Protocol to be configurable in fe2o3-amqp-ws #265

Closed brandonros closed 3 months ago

brandonros commented 3 months ago

It'd be nice if we could support something like this:

        this.ws = new WebSocket(`wss://${hostname}/$servicebus/websocket`, 'wsrelayedamqp', {
            protocolVersion: 13,
            headers: {
                'Host': hostname
            }
        });

wsrelayedamqp vs hardcoded amqp https://github.com/minghuaw/fe2o3-amqp/blob/701484d7e75f727dd96ea185ba6bf87b83c8c5b4/fe2o3-amqp-ws/src/native.rs#L299

minghuaw commented 3 months ago

I think this is required by the spec (see http://docs.oasis-open.org/amqp-bindmap/amqp-wsb/v1.0/csprd01/amqp-wsb-v1.0-csprd01.html#_Toc386635618)

Identifies the WebSocket subprotocol. For this AMQP WebSocket binding, the value MUST be set to the US-ASCII text string “AMQPWSB10” which refers to the 1.0 version of the AMQP Web Socket Binding as defined in this document.

If you want to customized value, I think you can use the WebSocketStream, split it into the reading and writing half, and then wrap it in SinkWriter and StreamReader, and probably need to create a new wrapper type and implement both AsyncRead and AsyncWrite. Then you can create a Connection with the method open_with_stream

brandonros commented 3 months ago

I think this is required by the spec

Wouldn't it make fe2o3-amqp more flexible/easier to use if it supported accepting a different string?