amqp / rhea

A reactive messaging library based on the AMQP protocol
Apache License 2.0
274 stars 80 forks source link

UserName, Password encoding as a part of connection to the websocket #136

Open pradip-interra opened 5 years ago

pradip-interra commented 5 years ago

Hello,

Thanks a lot for this wonderful library.

I have a few queries related to when I am setting up a connection. Something like I am using (from a TypeScript application, browserifying the Rhea):


const rhea = require('rhea.js');
var ws = rhea.websocket_connect(WebSocket);
var server = "wss://10.10.10.10:100/something/";
var connection_opts = {
  "host":  <===== What should I pass here? Whole wss://10.10.10.10:100/something/?
  "port": 100,
  "username": "user",
  "password": "password",
  "connection_details": ws(server, ["binary", "AMQPWSB10", "amqp"]),
  "reconnect": true,,
};
var connection = container.connect(connection_opts);
console.log(connection);

I have a couple of queries here:

  1. My server is say, wss://10.10.10.10:100/something/. What should I pass in "host" and "port" in connection options?

  2. I have a requirement to encode the username and password into the basic auth header as part of the connection to the WebSocket. How may I achieve it?

  3. This library seems supporting AMQP1.0. If I have a requirement to connect to a particular exchange (my application is only Receiver), can I able to do it using this library? I tried to search "exchange" in the whole rhea.js, it's not there (as it supports AMQP1.0).

If one can please provide the answers, would be of great help.

Thanks in advanced, Pradip (email: pradip.interra@gmail.com)

grs commented 5 years ago

My server is say, wss://10.10.10.10:100/something/. What should I pass in "host" and "port" in connection options?

You don't need to pass those in at all. The connection_details option is used instead.

I have a requirement to encode the username and password into the basic auth header as part of the connection to the WebSocket. How may I achieve it?

Try setting the username and password in the websocket url, e.g.

wss://user:password@10.10.10.10:100/something/

This library seems supporting AMQP1.0. If I have a requirement to connect to a particular exchange (my application is only Receiver), can I able to do it using this library? I tried to search "exchange" in the whole rhea.js, it's not there (as it supports AMQP1.0).

If the broker you are connecting to supports AMQP 1.0, then yes you should be able to.

pradip-interra commented 5 years ago

Thanks a lot for the answers above. I will try both answers 1 and 2 above. Thanks a ton.

I still have a question for 3rd query.

I studied the examples given here. However I am not seeing any example about how the container can connect to the particular exchange and get the notification from the exchange. In fact I searched the browserified rhea.js and did not able to get something called 'exchange' at all. Suppose my exchange name is - myexchange.master. Can it be possible to provide some clue how from the client code I can able to connect to a particular exchange and receive messages from there? That would be really enlightening for me.

Thanks in advanced, Pradip

grs commented 5 years ago

I'm not entirely sure what you mean by 'exchange'. Is this the pre 1.0 AMQP concept or something else? If the former, then you just use the receiver name as the source - e.g. as the argument to your open_receiver() call.

pradip-interra commented 5 years ago

I see. So basically this one(just to clarifying my own understanding)?


// receiver : to receive the messages coming from specified source var receiver_opts = { 'source': 'myexchange.master' 'target': 'local_target_name', // not necessary 'name': 'name_of_the_link', // not necessary 'credit_window': 500, // default 'autoaccept': true, //default }; var receiver = connection.open_receiver(receiver_opts);

Thanks in advanced, Pradip

grs commented 5 years ago

Yes